From 7d38048f334404a4901c36e1fc6bcdaa25e89690 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Fri, 29 Nov 2024 08:57:14 -0700 Subject: [PATCH] Fix crash with TS 5.5.x Resolves #2789 --- CHANGELOG.md | 4 +++ eslint.config.mjs | 11 +++++++++ package-lock.json | 26 ++++++++++---------- package.json | 2 +- src/lib/converter/comments/lineLexer.ts | 2 +- src/lib/models/reflections/declaration.ts | 2 +- src/lib/models/reflections/project.ts | 2 +- src/lib/models/types.ts | 2 +- src/lib/types/ts-internal/index.d.ts | 2 +- src/lib/utils/options/options.ts | 2 +- src/test/converter/declaration/external.d.ts | 2 +- src/test/converter2/issues/gh2552.js | 4 +-- 12 files changed, 38 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fba1429c0..b884624df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ title: Changelog ## Unreleased +### Bug Fixes + +- Fix crash with TypeScript 5.5.x, #2789. + ## v0.27.1 (2024-11-28) ### Bug Fixes diff --git a/eslint.config.mjs b/eslint.config.mjs index c933679c4..e745d7b4a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -102,6 +102,7 @@ const config = { "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/explicit-module-boundary-types": "off", + // https://astexplorer.net/#/gist/82d22728cda8283bf38e956640420af4/4d5e6fbcbceed981f9897a859322ade5f1cb86ee "no-restricted-syntax": [ "warn", { @@ -114,6 +115,16 @@ const config = { message: "Use type.getSymbol() instead, Type.symbol is not properly typed.", }, + { + selector: + "ImportDeclaration[source.value=typescript] ImportNamespaceSpecifier", + message: "TS before 5.7 does not have non-default exports.", + }, + { + selector: + "ImportDeclaration[source.value=typescript] ImportDeclaration", + message: "TS before 5.7 does not have non-default exports.", + }, ], "no-fallthrough": ["error", { allowEmptyCase: true }], diff --git a/package-lock.json b/package-lock.json index 5f285ad83..bac8bbef4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.27.1", "license": "Apache-2.0", "dependencies": { - "@gerrit0/mini-shiki": "^1.23.2", + "@gerrit0/mini-shiki": "^1.24.0", "lunr": "^2.3.9", "markdown-it": "^14.1.0", "minimatch": "^9.0.5", @@ -739,13 +739,13 @@ } }, "node_modules/@gerrit0/mini-shiki": { - "version": "1.23.2", - "resolved": "https://registry.npmjs.org/@gerrit0/mini-shiki/-/mini-shiki-1.23.2.tgz", - "integrity": "sha512-6e/41ZAilc2iE4n0bxxMSvzrt1dy2MSa9lSdd2M5lcTDlrzcau+FucIEDrG+xF1dPou/a093tm1t4HPTSI4g1w==", + "version": "1.24.0", + "resolved": "https://registry.npmjs.org/@gerrit0/mini-shiki/-/mini-shiki-1.24.0.tgz", + "integrity": "sha512-eopM3SyeUZQZSBu1VCV8/d1LtJXDd0aMpLjyWpGkjD6ux3sNwoLNeuEb5xmiWVfQvFeMUXa1WTjh06lqm3KETA==", "license": "MIT", "dependencies": { - "@shikijs/engine-oniguruma": "^1.23.1", - "@shikijs/types": "^1.23.1", + "@shikijs/engine-oniguruma": "^1.24.0", + "@shikijs/types": "^1.24.0", "@shikijs/vscode-textmate": "^9.3.0" } }, @@ -1001,19 +1001,19 @@ } }, "node_modules/@shikijs/engine-oniguruma": { - "version": "1.23.1", - "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.23.1.tgz", - "integrity": "sha512-KQ+lgeJJ5m2ISbUZudLR1qHeH3MnSs2mjFg7bnencgs5jDVPeJ2NVDJ3N5ZHbcTsOIh0qIueyAJnwg7lg7kwXQ==", + "version": "1.24.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.24.0.tgz", + "integrity": "sha512-Eua0qNOL73Y82lGA4GF5P+G2+VXX9XnuUxkiUuwcxQPH4wom+tE39kZpBFXfUuwNYxHSkrSxpB1p4kyRW0moSg==", "license": "MIT", "dependencies": { - "@shikijs/types": "1.23.1", + "@shikijs/types": "1.24.0", "@shikijs/vscode-textmate": "^9.3.0" } }, "node_modules/@shikijs/types": { - "version": "1.23.1", - "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.23.1.tgz", - "integrity": "sha512-98A5hGyEhzzAgQh2dAeHKrWW4HfCMeoFER2z16p5eJ+vmPeF6lZ/elEne6/UCU551F/WqkopqRsr1l2Yu6+A0g==", + "version": "1.24.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.24.0.tgz", + "integrity": "sha512-aptbEuq1Pk88DMlCe+FzXNnBZ17LCiLIGWAeCWhoFDzia5Q5Krx3DgnULLiouSdd6+LUM39XwXGppqYE0Ghtug==", "license": "MIT", "dependencies": { "@shikijs/vscode-textmate": "^9.3.0", diff --git a/package.json b/package.json index facd611a5..4b4d4fb82 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node": ">= 18" }, "dependencies": { - "@gerrit0/mini-shiki": "^1.23.2", + "@gerrit0/mini-shiki": "^1.24.0", "lunr": "^2.3.9", "markdown-it": "^14.1.0", "minimatch": "^9.0.5", diff --git a/src/lib/converter/comments/lineLexer.ts b/src/lib/converter/comments/lineLexer.ts index 4a2fff84d..feb1dfbc8 100644 --- a/src/lib/converter/comments/lineLexer.ts +++ b/src/lib/converter/comments/lineLexer.ts @@ -1,4 +1,4 @@ -import type * as ts from "typescript"; +import type ts from "typescript"; import { type Token, TokenSyntaxKind } from "./lexer.js"; export function* lexLineComments( diff --git a/src/lib/models/reflections/declaration.ts b/src/lib/models/reflections/declaration.ts index cf7843956..e53f7f8d4 100644 --- a/src/lib/models/reflections/declaration.ts +++ b/src/lib/models/reflections/declaration.ts @@ -1,4 +1,4 @@ -import type * as ts from "typescript"; +import type ts from "typescript"; import { type ReferenceType, ReflectionType, type SomeType } from "../types.js"; import { type TraverseCallback, TraverseProperty } from "./abstract.js"; import { ContainerReflection } from "./container.js"; diff --git a/src/lib/models/reflections/project.ts b/src/lib/models/reflections/project.ts index 4d6683d58..ea35ff21d 100644 --- a/src/lib/models/reflections/project.ts +++ b/src/lib/models/reflections/project.ts @@ -1,4 +1,4 @@ -import type * as ts from "typescript"; +import type ts from "typescript"; import { type Reflection, TraverseProperty } from "./abstract.js"; import { ContainerReflection } from "./container.js"; import { ReferenceReflection } from "./reference.js"; diff --git a/src/lib/models/types.ts b/src/lib/models/types.ts index 41ea35930..e91a3c26e 100644 --- a/src/lib/models/types.ts +++ b/src/lib/models/types.ts @@ -1,4 +1,4 @@ -import * as ts from "typescript"; +import ts from "typescript"; import type { Context } from "../converter/index.js"; import type { Reflection } from "./reflections/abstract.js"; import type { DeclarationReflection } from "./reflections/declaration.js"; diff --git a/src/lib/types/ts-internal/index.d.ts b/src/lib/types/ts-internal/index.d.ts index dfee92d49..f38dbc744 100644 --- a/src/lib/types/ts-internal/index.d.ts +++ b/src/lib/types/ts-internal/index.d.ts @@ -1,4 +1,4 @@ -import type * as ts from "typescript"; +import type ts from "typescript"; /** * Expose the internal TypeScript APIs that are used by TypeDoc diff --git a/src/lib/utils/options/options.ts b/src/lib/utils/options/options.ts index daa9f2a6f..c3d68f423 100644 --- a/src/lib/utils/options/options.ts +++ b/src/lib/utils/options/options.ts @@ -1,4 +1,4 @@ -import type * as ts from "typescript"; +import type ts from "typescript"; import { resolve } from "path"; import { ParameterType } from "./declaration.js"; import type { NeverIfInternal, OutputSpecification } from "../index.js"; diff --git a/src/test/converter/declaration/external.d.ts b/src/test/converter/declaration/external.d.ts index e0fc49b1c..daba25aab 100644 --- a/src/test/converter/declaration/external.d.ts +++ b/src/test/converter/declaration/external.d.ts @@ -1,3 +1,3 @@ -import * as ts from "typescript"; +import ts from "typescript"; export const ActionSet: ts.server.ActionSet; diff --git a/src/test/converter2/issues/gh2552.js b/src/test/converter2/issues/gh2552.js index d4d97f3a0..295ccc83c 100644 --- a/src/test/converter2/issues/gh2552.js +++ b/src/test/converter2/issues/gh2552.js @@ -6,12 +6,12 @@ */ // TS 5.5 @import comments -/** @import * as ts from "typescript" */ +/** @import ts from "typescript" */ /** * This is an awesome module. * @module good-module */ -/** @import * as ts2 from "typescript" */ +/** @import ts2 from "typescript" */ export const something = 1;