Skip to content

Generate types from TypeScript dialect JSDoc#556

Merged
fatso83 merged 1 commit intomainfrom
jsdoc-types-generation
Apr 2, 2026
Merged

Generate types from TypeScript dialect JSDoc#556
fatso83 merged 1 commit intomainfrom
jsdoc-types-generation

Conversation

@fatso83
Copy link
Copy Markdown
Contributor

@fatso83 fatso83 commented Apr 1, 2026

closes #520

Purpose (TL;DR) - mandatory

  • Get generated types from the source code to avoid keeping external types up to date
  • Type check the code we write to ensure it is in sync with our produced types

Background (Problem in detail) - optional

See explanation in #520
@mantoni suggested in #520 to use JSDoc with TS flavor to avoid having to write TS, while having the benefits

Solution - optional

Use native build of TS transpiler for speed.

The code will be type checked, even if still written in js.

Named callbacks are used instead of inline function types because the current version of tsgo (TypeScript 7 native preview) often generates invalid syntax like (: function) when encountering anonymous function types in JSDoc.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 1, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​typescript/​native-preview@​7.0.0-dev.20260401.110010072100100
Updated@​types/​node@​24.5.2 ⏵ 25.5.0100 +110081 +195100

View full report

@fatso83 fatso83 force-pushed the jsdoc-types-generation branch from f433db3 to fe3ea68 Compare April 1, 2026 23:51
The means all generated types will be in sync with the source code,
always.

Named callbacks are used instead of inline function types because the current
version of tsgo (TypeScript 7 native preview) often generates invalid syntax
like (: function) when encountering anonymous function types in JSDoc.

closes #520

docs: prepare fake-timers JSDoc types for generation

feat: generate fake-timers declarations from JSDoc

chore: add tsgo preview validation for types

chore: ship bundled fake-timers types

chore: update types and lockfile

docs: finalize JSDoc types migration plan

chore: update types with Date instead of DateConstructor

docs: finalize JSDoc types migration plan

chore: refine JSDoc to match DefinitelyTyped precision

feat: use tsgo exclusively for type generation and validation

refactor: ts-typed lambdas instead of named types

chore: use named @callback for robust tsgo declaration generation

Named callbacks are used instead of inline function types because the current
version of tsgo (TypeScript 7 native preview) often generates invalid syntax
like (: function) when encountering anonymous function types in JSDoc.
This approach ensures syntactically correct .d.ts files while maintaining
direct source-to-type linkage.

fix: enabled type checks and fixed all 147 type errors

test: test timers.queueMicrotask in consumer
@fatso83 fatso83 force-pushed the jsdoc-types-generation branch from fe3ea68 to 93d150e Compare April 2, 2026 00:04
@fatso83 fatso83 merged commit 8f096a8 into main Apr 2, 2026
11 checks passed
@fatso83 fatso83 deleted the jsdoc-types-generation branch April 2, 2026 00:05
return 0;
}
if (typeof epoch.getTime === "function") {
if (epoch instanceof Date) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion: Convert to Typescript

2 participants