-
Notifications
You must be signed in to change notification settings - Fork 5
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
inferExtension doesn't work with typescript def #3
Comments
I hadn't considered/tried the TS definition case. I suspect JSDoc won't be able to understand TS files, you'll likely need TSDoc for that. However, there does seem to be a bug you're describing where this plugin shouldn't fail if the jsdoc points to a .d.ts file. I'll check it out and possibly make a separate ticket. PR requests are also welcome if you come up with a simple solution. |
Thanks @nbilyk. I'm using a plugin called better-docs to incorporate the TS defs into JSDoc. This is a much better solution where I can use TS defs to describe my types than have to create JSDoc comments |
I did propose a solution in the ticket, however I don't know if that's sufficient. |
It might be, I'm looking into it. The question is how does TypeScript expect to resolve the file. For example if foo.bar.js should be referenced in the import as "foo.bar" that would break, so I'm doing a few tests first. |
I've identified 3 cases to handle -
|
Give 1.0.4 a try Note that the fix doesn't interop between jsdoc and tsdoc, the fix just prevents a crash when the referenced file can't be resolved. |
Thanks. |
I'm wanting to use this plugin with my project where the source is in Javascript, but we have types defined in Typescript that's imported from a company module (we also have local TS defs to the project). Because the types are in TS declaration files, they have a
.d.ts
extension.If I try to type my JS var and then generate the documentation, it fails.
For example
Looking at the source I think it's because
path.extname
is not stripping off the.d
which means thatMyType
!==MyType.d
sofind
returnsundefined
which causesjoin
to blow up.A possible solution would be to substring from the first
.
found eg:filename.substring(0, filename.indexOf("."))
This would seeMyType.d.ts
andMyType.ts
becomeMyType
The text was updated successfully, but these errors were encountered: