docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

change types to declaration file

Open omonk opened this issue 3 weeks ago • 5 comments

Description

Change packages/docusaurus-plugin-openapi-docs/src/types.ts to a declaration file.

Motivation and Context

Following on from https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/1220 we are still not able to run typescript checking across our site due to issues with how the internal types are defined in this package.

I have copied the docusaurus tsconfig from here into our repo https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-tsconfig/tsconfig.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Docusaurus",
  "docs": "https://docusaurus.io/docs/typescript-support",
  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "jsx": "preserve",
    "target": "ES2022",
    "lib": ["ES2022", "DOM"],
    "moduleResolution": "bundler",
    "module": "esnext",
    "noEmit": true,
    "paths": {
      "@site/*": ["./*"]
    },
    "skipLibCheck": true
  },
  "include": ["api/", "src/", "scripts/"],
  "exclude": [".docusaurus", "build", "node_modules"]
}

Currently if I attempt to typecheck the repo we are still seeing errors from this package

yarn run tsc:check
node_modules/docusaurus-plugin-openapi-docs/src/types.ts:8:32 - error TS2307: Cannot find module '@docusaurus/plugin-content-docs/src/sidebars/types' or its corresponding type declarations.

8 import { SidebarItemDoc } from "@docusaurus/plugin-content-docs/src/sidebars/types";
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/docusaurus-plugin-openapi-docs/src/types.ts:24:8 - error TS2307: Cannot find module '@docusaurus/plugin-content-docs-types' or its corresponding type declarations.

24 } from "@docusaurus/plugin-content-docs-types";
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

skipLibCheck will only skip .d.ts files. If I change my local node module to .d.ts these errors go away.

How Has This Been Tested?

This repo will still build successfully with these changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes if appropriate.
  • [x] All new and existing tests passed.

omonk avatar Dec 04 '25 16:12 omonk