Skip to content

Commit

Permalink
Support TypeScript 5.4
Browse files Browse the repository at this point in the history
Resolves #2517
Closes #2519
  • Loading branch information
Gerrit0 committed Mar 10, 2024
1 parent c3ae6ec commit e718b09
Show file tree
Hide file tree
Showing 8 changed files with 635 additions and 571 deletions.
464 changes: 232 additions & 232 deletions example/package-lock.json

Large diffs are not rendered by default.

693 changes: 368 additions & 325 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Expand Up @@ -30,24 +30,24 @@
"shiki": "^0.14.7"
},
"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"
"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"
},
"devDependencies": {
"@types/lunr": "^2.3.5",
"@types/lunr": "^2.3.7",
"@types/marked": "^4.0.8",
"@types/mocha": "^10.0.2",
"@types/mocha": "^10.0.6",
"@types/node": "16",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#8abd1494280116ff5318dde2c50ad01e1663790c",
"c8": "^8.0.1",
"esbuild": "^0.19.11",
"eslint": "^8.56.0",
"mocha": "^10.2.0",
"c8": "^9.1.0",
"esbuild": "^0.20.1",
"eslint": "^8.57.0",
"mocha": "^10.3.0",
"prettier": "3.0.3",
"puppeteer": "^13.5.2",
"ts-node": "^10.9.2",
"typescript": "5.3.3"
"typescript": "5.4.2"
},
"files": [
"/bin",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/converter/types.ts
Expand Up @@ -676,8 +676,10 @@ const queryConverter: TypeConverter<ts.TypeQueryNode> = {
return new QueryType(ref);
},
convertType(context, type, node) {
// Order matters here - check the node location first so that if the typeof is targeting
// an instantiation expression we get the user's exprName.
const symbol =
type.getSymbol() || context.getSymbolAtLocation(node.exprName);
context.getSymbolAtLocation(node.exprName) || type.getSymbol();
assert(
symbol,
`Query type failed to get a symbol for: ${context.checker.typeToString(
Expand Down
8 changes: 6 additions & 2 deletions src/lib/utils/options/declaration.ts
Expand Up @@ -261,8 +261,12 @@ export type KeyToDeclaration<K extends keyof TypeDocOptionMap> =
? MixedDeclarationOption | ObjectDeclarationOption
: TypeDocOptionMap[K] extends ManuallyValidatedOption<unknown>
?
| (MixedDeclarationOption & { validate(value: unknown): void })
| (ObjectDeclarationOption & { validate(value: unknown): void })
| (MixedDeclarationOption & {
validate(value: unknown): void;
})
| (ObjectDeclarationOption & {
validate(value: unknown): void;
})
: TypeDocOptionMap[K] extends Record<string, boolean>
? FlagsDeclarationOption<TypeDocOptionMap[K]>
: TypeDocOptionMap[K] extends Record<string | number, infer U>
Expand Down
8 changes: 8 additions & 0 deletions src/test/behavior.c2.test.ts
Expand Up @@ -1171,4 +1171,12 @@ describe("Behavior Tests", () => {

logger.expectNoMessage("debug: Refusing to recurse*");
});

it("Handles NoInfer intrinsic type", () => {
const project = convert("noInfer");
const sig = querySig(project, "createStreetLight");
equal(sig.parameters?.length, 2);
equal(sig.parameters[0].type?.toString(), "C[]");
equal(sig.parameters[1].type?.toString(), "NoInfer");
});
});
2 changes: 1 addition & 1 deletion src/test/capture-screenshots.ts
Expand Up @@ -37,7 +37,7 @@ class PQueue {
const nextPromise = Promise.resolve().then(next);
queue.push(nextPromise);
nextPromise.then(() => {
queue.splice(queue.indexOf(nextPromise), 1);
void queue.splice(queue.indexOf(nextPromise), 1);
tick();
}, doReject);
} else {
Expand Down
7 changes: 7 additions & 0 deletions src/test/converter2/behavior/noInfer.ts
@@ -0,0 +1,7 @@
export function createStreetLight<C extends string>(
colors: C[],
defaultColor?: NoInfer<C>,
) {}

// @ts-expect-error
createStreetLight(["red", "yellow", "green"], "blue");

0 comments on commit e718b09

Please sign in to comment.