Skip to content

feat: add typescript type declarations for all packages#649

Open
salama968 wants to merge 2 commits intoaccordproject:mainfrom
salama968:salama968/i648/add-typescript-types
Open

feat: add typescript type declarations for all packages#649
salama968 wants to merge 2 commits intoaccordproject:mainfrom
salama968:salama968/i648/add-typescript-types

Conversation

@salama968
Copy link

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

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Signed-off-by: ahmedsalama <slamah968@gmail.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.ts entrypoints and module typings under types/ for each package.
  • Add per-package tsconfig.json (allowJs + emitDeclarationOnly) and build:types scripts (often chained into build).
  • 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

Signed-off-by: ahmedsalama <slamah968@gmail.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 98 changed files in this pull request and generated 2 comments.

"outDir": "types",
"strict": false
},
"include": ["index.js", "lib/**/*.js"]
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

This tsconfig.json includes lib/**/*.js, and this package keeps Jest test files alongside runtime code in lib/ (e.g., *.test.js). That causes tsc to emit .test.d.ts files into types/ and they may get published via the types folder. Add an exclude (or narrow include) to prevent test files from being part of the public typings output, then regenerate/clean the generated declarations.

Suggested change
"include": ["index.js", "lib/**/*.js"]
"include": ["index.js", "lib/**/*.js"],
"exclude": ["lib/**/*.test.js"]

Copilot uses AI. Check for mistakes.
"outDir": "types",
"strict": false
},
"include": ["index.js", "lib/**/*.js"]
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

This tsconfig.json includes lib/**/*.js, and this package has test files under lib/ (e.g., *.test.js). As a result, running tsc will emit test declaration stubs into types/, which is usually not intended for published typings. Add an exclude (or narrow the include) to omit test files and regenerate the types/ output.

Suggested change
"include": ["index.js", "lib/**/*.js"]
"include": ["index.js", "lib/**/*.js"],
"exclude": ["lib/**/*.test.js", "lib/**/__tests__/**/*"]

Copilot uses AI. Check for mistakes.
@salama968
Copy link
Author

@mttrbrts i resolved all the previous suggestions

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.

Add Typescript types

2 participants