Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDoc plugin is not working properly #191

Open
just-jeb opened this issue Dec 26, 2022 · 4 comments
Open

JSDoc plugin is not working properly #191

just-jeb opened this issue Dec 26, 2022 · 4 comments

Comments

@just-jeb
Copy link

just-jeb commented Dec 26, 2022

I'm trying to migrate a JS project (that contains JSDoc annotations) to TS project.
So far I've been able to come to a point where all my files are TS, everything compiles and the bundle is produced.

However, when I try to run JSDoc plugin and hopefully convert all the JSDoc annotations to proper TS types it doesn't really work.
This is what I do (and the output):

npx ts-migrate migrate --plugin jsdoc packages/my-project
TypeScript version: 4.9.4
Initialized tsserver project in 81ms.
Start...
[jsdoc] Plugin 1 of 1. Start...
[jsdoc] Finished in 7ms.
Finished in 7ms, for 1 plugin(s).
Writing 0 updated file(s)...
Wrote 0 updated file(s) in 1ms.

This is my tsconfig.json (located at packages/my-project):

{
  "compilerOptions": {
    "target": "ES2017",
    "module": "ESNext",
    "allowJs": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true,
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "rootDir": "src",
    "outDir": "dist/esm",
    "noImplicitAny": false,
    "declarationDir": "dist/types",
    "declaration": true
  },
  "compileOnSave": false,
  "include": [
    "src"
  ]
}

And this is an example for one of the JSDoc annotations located in one of the files (say packages/my-project/src/example.ts):

/**
 * @param {Promise<{entryType: string}>[]} entries
 * @param {Promise} aPromise
 * @param {import('./entries/result').Result} result
 */
export default function foo(
  entries,
  aPromise,
  results,
) {
// implementation here
}

I would expect this JSDoc to be transformed into typed signature. Did I get that wrong? Isn't it what the JSDoc plugin supposed to do? Or am I just using it the wrong way?

P.S. I also tried to use older version (as it seemed to solve the issue earlier), but it didn't help.

@kotmatpockuh
Copy link

did you solve it @just-jeb ?

@just-jeb
Copy link
Author

Nope I gave up 😅.

@Laberbear
Copy link

Nope I gave up 😅.

por favor señor, I got a solution for you right here.
(at least the one that worked for us)

We had to downgrade our typescript version in the project to 4.7.2 (which is the one used for this package)
So just run

npm install -D [email protected]
or
yarn add -D [email protected]

And then try to run your migration.js file or the extremely well documented CLI.

Hope it works for you,
best wishes and happy new year.

@connorjclark
Copy link

@Laberbear absolutely fantastic, this worked and saved me so much time, thank you for sharing this workaround!

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

No branches or pull requests

4 participants