feat: add typescript type declarations for all packages#649
feat: add typescript type declarations for all packages#649salama968 wants to merge 5 commits intoaccordproject:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds published TypeScript declaration files across the markdown-transform monorepo packages by introducing per-package tsconfig.json declaration emit, wiring build:types scripts, and updating package manifests to ship a /types directory via the typings field.
Changes:
- Add generated
.d.tsentrypoints and module typings undertypes/for each package. - Add per-package
tsconfig.json(allowJs + emitDeclarationOnly) andbuild:typesscripts (often chained intobuild). - Apply targeted JSDoc tweaks to unblock declaration emit (e.g., rule exports typing, JSDoc return types).
Reviewed changes
Copilot reviewed 21 out of 98 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Add root TypeScript devDependency |
| package-lock.json | Lockfile updates for TypeScript + peers |
| packages/markdown-transform/package.json | Publish types + build:types script |
| packages/markdown-transform/tsconfig.json | Emit declarations to types/ |
| packages/markdown-transform/types/index.d.ts | Package typings entrypoint |
| packages/markdown-transform/types/lib/builtinTransforms.d.ts | Generated builtin transforms typings |
| packages/markdown-transform/types/lib/transform.d.ts | Generated transform API typings |
| packages/markdown-transform/types/lib/transformEngine.d.ts | Generated TransformEngine typings |
| packages/markdown-template/package.json | Publish types + build:types script |
| packages/markdown-template/tsconfig.json | Emit declarations to types/ |
| packages/markdown-template/lib/templatemarkutil.js | JSDoc return type adjusted for emit |
| packages/markdown-template/src/templatemarkutil.js | JSDoc return type adjusted for emit |
| packages/markdown-template/types/index.d.ts | Package typings entrypoint |
| packages/markdown-template/types/lib/FormulaVisitor.d.ts | Generated visitor typings |
| packages/markdown-template/types/lib/ModelVisitor.d.ts | Generated visitor typings |
| packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts | Generated transformer typings |
| packages/markdown-template/types/lib/ToCiceroMarkVisitor.d.ts | Generated visitor typings |
| packages/markdown-template/types/lib/ToMarkdownTemplateVisitor.d.ts | Generated visitor typings |
| packages/markdown-template/types/lib/ToParserVisitor.d.ts | Generated visitor typings |
| packages/markdown-template/types/lib/TypeVisitor.d.ts | Generated visitor typings |
| packages/markdown-template/types/lib/datetimeutil.d.ts | Generated util typings |
| packages/markdown-template/types/lib/errorutil.d.ts | Generated util typings |
| packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts | Generated rules typings |
| packages/markdown-template/types/lib/normalize.d.ts | Generated normalize typings |
| packages/markdown-template/types/lib/templateexception.d.ts | Generated exception typings |
| packages/markdown-template/types/lib/templatemarkutil.d.ts | Generated util typings |
| packages/markdown-template/types/lib/templaterules.d.ts | Generated template rules typings |
| packages/markdown-template/types/lib/toparserrules.d.ts | Generated parser rules typings |
| packages/markdown-template/types/lib/util.d.ts | Generated util typings |
| packages/markdown-it-template/package.json | Publish types + build:types script |
| packages/markdown-it-template/tsconfig.json | Emit declarations to types/ |
| packages/markdown-it-template/types/index.d.ts | Package typings entrypoint |
| packages/markdown-it-template/types/lib/index.d.ts | Generated plugin typings |
| packages/markdown-it-template/types/lib/template_block.d.ts | Generated block rule typings |
| packages/markdown-it-template/types/lib/template_block_render.d.ts | Generated renderer typings |
| packages/markdown-it-template/types/lib/template_inline.d.ts | Generated inline rule typings |
| packages/markdown-it-template/types/lib/template_inline_render.d.ts | Generated renderer typings |
| packages/markdown-it-template/types/lib/template_re.d.ts | Generated regex helpers typings |
| packages/markdown-it-cicero/package.json | Publish types + build:types script |
| packages/markdown-it-cicero/tsconfig.json | Emit declarations to types/ |
| packages/markdown-it-cicero/types/index.d.ts | Package typings entrypoint |
| packages/markdown-it-cicero/types/lib/cicero_block.d.ts | Generated block rule typings |
| packages/markdown-it-cicero/types/lib/cicero_block_render.d.ts | Generated renderer typings |
| packages/markdown-it-cicero/types/lib/cicero_inline.d.ts | Generated inline rule typings |
| packages/markdown-it-cicero/types/lib/cicero_re.d.ts | Generated regex helpers typings |
| packages/markdown-it-cicero/types/lib/index.d.ts | Generated plugin typings |
| packages/markdown-html/package.json | Publish types + build:types script |
| packages/markdown-html/tsconfig.json | Emit declarations to types/ |
| packages/markdown-html/types/index.d.ts | Package typings entrypoint |
| packages/markdown-html/types/lib/HtmlTransformer.d.ts | Generated transformer typings |
| packages/markdown-html/types/lib/HtmlTransformer.test.d.ts | Generated test declaration output |
| packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts | Generated visitor typings |
| packages/markdown-html/types/lib/ToHtmlStringVisitor.d.ts | Generated visitor typings |
| packages/markdown-html/types/lib/helpers.d.ts | Generated helper typings |
| packages/markdown-html/types/lib/rules.d.ts | Generated rules typings |
| packages/markdown-common/package.json | Publish types + build:types script |
| packages/markdown-common/tsconfig.json | Emit declarations to types/ |
| packages/markdown-common/lib/FromCommonMarkVisitor.js | JSDoc adjusted for emit |
| packages/markdown-common/lib/fromcommonmarkrules.js | Rules export typing for emit |
| packages/markdown-common/types/index.d.ts | Package typings entrypoint |
| packages/markdown-common/types/lib/CommonMarkSpec.test.d.ts | Generated test declaration output |
| packages/markdown-common/types/lib/CommonMarkTransformer.d.ts | Generated transformer typings |
| packages/markdown-common/types/lib/CommonMarkTransformer.test.d.ts | Generated test declaration output |
| packages/markdown-common/types/lib/CommonMarkUtils.d.ts | Generated utils typings |
| packages/markdown-common/types/lib/FromCommonMarkVisitor.d.ts | Generated visitor typings |
| packages/markdown-common/types/lib/FromMarkdownIt.d.ts | Generated transformer typings |
| packages/markdown-common/types/lib/FromMarkdownIt.test.d.ts | Generated test declaration output |
| packages/markdown-common/types/lib/Stack.d.ts | Generated Stack typings |
| packages/markdown-common/types/lib/Stack.test.d.ts | Generated test declaration output |
| packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts | Generated visitor typings |
| packages/markdown-common/types/lib/ToMarkdownVisitor.test.d.ts | Generated test declaration output |
| packages/markdown-common/types/lib/externalModels/CiceroMarkModel.d.ts | Generated external model typings |
| packages/markdown-common/types/lib/externalModels/CommonMarkModel.d.ts | Generated external model typings |
| packages/markdown-common/types/lib/externalModels/ConcertoMetaModel.d.ts | Generated external model typings |
| packages/markdown-common/types/lib/externalModels/TemplateMarkModel.d.ts | Generated external model typings |
| packages/markdown-common/types/lib/fromcommonmarkrules.d.ts | Generated rules typings |
| packages/markdown-common/types/lib/removeFormatting.d.ts | Generated helper typings |
| packages/markdown-common/types/lib/tocommonmarkrules.d.ts | Generated rules typings |
| packages/markdown-cli/package.json | Publish types + build:types script |
| packages/markdown-cli/tsconfig.json | Emit declarations to types/ |
| packages/markdown-cli/types/index.d.ts | Generated index declaration |
| packages/markdown-cli/types/lib/commands.d.ts | Generated Commands typings |
| packages/markdown-cicero/package.json | Publish types + build:types script |
| packages/markdown-cicero/tsconfig.json | Emit declarations to types/ |
| packages/markdown-cicero/types/index.d.ts | Package typings entrypoint |
| packages/markdown-cicero/types/lib/CiceroEditTransformer.test.d.ts | Generated test declaration output |
| packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts | Generated transformer typings |
| packages/markdown-cicero/types/lib/CiceroMarkTransformer.test.d.ts | Generated test declaration output |
| packages/markdown-cicero/types/lib/CommonMarkSpec.test.d.ts | Generated test declaration output |
| packages/markdown-cicero/types/lib/Decorators.d.ts | Generated helper typings |
| packages/markdown-cicero/types/lib/Decorators.test.d.ts | Generated test declaration output |
| packages/markdown-cicero/types/lib/FromCiceroEditVisitor.d.ts | Generated visitor typings |
| packages/markdown-cicero/types/lib/ToCiceroMarkUnwrappedVisitor.d.ts | Generated visitor typings |
| packages/markdown-cicero/types/lib/ToCommonMarkVisitor.d.ts | Generated visitor typings |
| packages/markdown-cicero/types/lib/ToMarkdownCiceroVisitor.d.ts | Generated visitor typings |
| packages/markdown-cicero/types/lib/UnquoteVariables.d.ts | Generated helper typings |
| packages/markdown-cicero/types/lib/cicerorules.d.ts | Generated rules typings |
| packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts | Generated rules typings |
|
@mttrbrts i resolved all the previous suggestions |
Signed-off-by: ahmedsalama <slamah968@gmail.com>
Signed-off-by: ahmedsalama <slamah968@gmail.com>
e58c8ba to
45af3df
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: ahmedsalama <slamah968@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: ahmedsalama <slamah968@gmail.com>
45af3df to
afb3cb3
Compare
|
@mttrbrts I resolved all the merge conflicts |
|
@salama968, can you resolve the merge conflict? I’m also looking into it. cc: @mttrbrts |
|
Hi @mttrbrts, I went through the PR and the earlier Copilot comments mostly look resolved. One thing I’d still flag: there are still generated test declaration files in the current diff, for example:
Since the packages now publish the |
Signed-off-by: ahmedsalama <slamah968@gmail.com>
Closes #648
Changes
Changes per package:
Infrastructure: Added typescript@^5.9.3 to devDependencies and created package-specific tsconfig.json files.
Scripts: Added build:types (linked to the main build script) to automate declaration generation.
Publishing: Added the typings field to package.json and included the types directory in the files array for NPM releases.
JSDoc & Type Fixes
To unblock the tsc declaration emit and resolve compiler errors, the following fixes were applied:
fromcommonmarkrules.js: Added explicit @type {Object<string, Function>} to the rules export to resolve TS9006 (private name requirement).
FromCommonMarkVisitor.js: Corrected the constructor JSDoc to ensure required parameters do not follow optional ones (TS1016).
templatemarkutil.js: Updated @returns {ClassDeclaration} to {object} to resolve external type dependency issues where the runtime type was unknown to the compiler.
Author Checklist
--signoffoption of git commit.mainfromfork:branchname