So in a JavaScript-only repo, with no .ts
files, just using JSDocs, you have something like:
./types.js
/** @typedef {'html'|'xhtml'|'xml'} MARKUPTYPE */
./src/loadOptions.js
/** @typedef {import('../types.js').MARKUPTYPE} MARKUPTYPE */
/**
* Some function.
*
* @param {MARKUPTYPE} markup
* @return {void}
*/
export const someFunction = function (markup) {
console.log(markup);
};
And then the stupid TS Engine in VSCodium goes "OMG! I CAN'T IMPORT THAT! IT'S NOT A MODULE!!!!!! WHAT COULD IT EVEN BE?????"
So all you have to do apparently is add this to the end of your types.js
file:
export const LITERALLY_ANYTHING_IT_DOES_NOT_MATTER_WHAT_THIS_VARIABLE_IS_CALLED_OR_WHAT_IT_IS_ASSIGNED_TO_TYPESCRIPT_IS_INCREDIBLY_STUPID_AND_NEEDS_THIS_HAND_HOLDING_BECAUSE_IT_IS_A_BAD_TECHNOLOGY = {};
And then the stupid fucking typescript engine will understand it's a module. It can't POSSIBLY look at the "type": "module"
in the package.json
and infer that all .js
files are modules. Noooooooo, that would be convenient and the obvious way to do things, which is antithetical to the TS mission.
TypeScript, succeeding again in wasting 30 minutes of time to GIVE ABSOLUTELY NO TANGIBLE VALUE OR BENEFIT.
We could have had flying cars, but we chose suffering.