Skip to content

Commit

Permalink
chore(compartment-mapper): fix type of internal function
Browse files Browse the repository at this point in the history
This addresses the `@ts-ignore` found in `makeFauxModuleExportsNamespace()`, which was renamed from `makeFeauxModuleExportsNamespace()`, because "féaux" translates to "loyal supporters" and not "fake" or "false" like was presumably intended.

I am not so bold to rename it `makeErsatzModuleExportsNamespace()`, despite "ersatz" being a wholly superior word to either of the above alternatives.
  • Loading branch information
boneskull committed Jan 22, 2024
1 parent bb2833f commit ef80984
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/compartment-mapper/src/import-archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,25 @@ const makeArchiveImportHookMaker = (
return makeImportHook;
};

const makeFeauxModuleExportsNamespace = Compartment => {
// @ts-ignore Unclear at time of writing why Compartment type is not
// constructible.
/**
* Creates a fake module namespace object that passes a brand check.
*
* @param {typeof Compartment} Compartment
* @returns {import('ses').ModuleExportsNamespace}
*/
const makeFauxModuleExportsNamespace = Compartment => {
const compartment = new Compartment(
{},
{},
{
resolveHook() {
return '.';
},
importHook() {
async importHook() {
return {
imports: [],
execute() {},
exports: [],
};
},
},
Expand Down Expand Up @@ -336,7 +341,7 @@ export const parseArchive = async (
parserForLanguage,
modules: Object.fromEntries(
Object.keys(modules || {}).map(specifier => {
return [specifier, makeFeauxModuleExportsNamespace(Compartment)];
return [specifier, makeFauxModuleExportsNamespace(Compartment)];
}),
),
Compartment,
Expand Down

0 comments on commit ef80984

Please sign in to comment.