I have a module
camera.d.js
that only contains the following definition:
/**
* @typedef {object} CropperConfiguration
* @property {Dimension} dimensions - Dimensions.
*/
and imports the module
global.d.js
that contains the following definition:
/**
* @typedef {object} Dimension
* @property {number} width - Width.
* @property {number} height - Height.
*/
So... if camera.d.js imports global.d.js... in my module CameraUtils.js, that imports camera.d.js, do I need to import global.d.js to access the Dimension definition?
I thought that yes, but... for some reason I don't understand, I can perfectly access this definition only importing camera.d.js and ignoring global.d.js.
Why?
--
Full content of camera.d.js
/**
* @file Camera type definitions.
* @license MIT
* @version 1.0.0
* @since 1.0.0
* @category utils
* @subcategory camera
* @module CameraTypes
*/
import "../global/global.d";
/**
* @typedef {object} CropperConfiguration
* @property {Dimension} dimensions - Dimensions.
* @property {string} name - Cropper's vector icon name.
* @property {string} type - Cropper's vector icon type.
*/
And... for importing the types in CameraUtils.js I just do:
import "./camera.d"; // global scope
...
I've been using JSDocs with VSCode IntelliSence for a few years now. By default, it's disabled, so you have to enable it first:
https://code.visualstudio.com/docs/languages/jsconfig
I have a public project you can reference from here:
https://github.com/clshortfuse/webhoster/blob/master/jsconfig.json
But basically, you need:
{
"compilerOptions": {
"checkJs": true,
}
}
You don't need a.d.js file. You can inline them. You can also use a .d.ts file for complex types and then import the .js equivalent inline.
See: https://github.com/clshortfuse/webhoster/tree/master/types