Any resources for JSDoc + AMD? #23
Unanswered
BennyHinrichs
asked this question in
Questions
Replies: 1 comment
-
I figured out a way to do it, but I don't love it // Ancestor.js
define([], Module);
function Module() {return {foo: 'bar'}};
/** @typedef {ReturnType<Module>} Ancestor */
export const Types = {};
// Child.js
import * as AncestorTypes from './Ancestor';
define(['Ancestor'], Module);
/** @param {AncestorTypes.Ancestor} Super */
function Module(Super) {return Super.foo} This gets you type completions between AMD files (using a dummy object to import the whole namespace). Then I guess you either hope that your bundler sees the unused import/exports and strips them out, or you add code in your bundler setup to do that. Similar deal if you need to add types from a library. Save it as a dev dependency, import it into your file, then remove the import from the actual output. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on an older codebase that for reasons can't be transitioned to ESM. I've been desperately trying to find examples of getting JSDoc to work with AMD, but still haven't been able to get types from one file to show up in another. The closest I could find was this repo: https://github.com/ibm-js/jsdoc-amddcl. But it seems to use a library called
dcl
that I can't add to my project.I've tried to do something like
I've tried throwing in
@lends
in a few different locations.I've tried adding in
/// <reference path="./Ancestor.js" />
then referencingAncestor
.Nothing I try seems to get types from Ancestor to show up in Child.
Beta Was this translation helpful? Give feedback.
All reactions