Skip to content

Commit

Permalink
fix: only set Utility property if namespace empty
Browse files Browse the repository at this point in the history
If the Utility namespace has concrete values and the const Utility
property is set it causes `error TS2300: Duplicate identifier 'Utility'.`
This tracks whether any values are added to the Utility namespace and
only sets the property workaround if there are none.
  • Loading branch information
devm33 committed Oct 25, 2023
1 parent a3a0ea0 commit 89617c3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/primary-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const generatePrimaryInterfaces = (
}
};

let utilityNamespaceHasValues = false;

API.forEach((module, index) => {
if (module.name === 'process') return;
let TargetNamespace;
Expand Down Expand Up @@ -102,11 +104,18 @@ export const generatePrimaryInterfaces = (
);
TargetNamespace.push(...declarations);
CrossProcessExportsNamespace.push(...declarations);
if (module.process.utility) UtilityNamespace.push(...declarations);
if (module.process.utility) {
UtilityNamespace.push(...declarations);
if (newConstDeclarations.length > 0) {
utilityNamespaceHasValues = true;
}
}
}
});

constDeclarations.push('const Utility: {};');
if (!utilityNamespaceHasValues) {
constDeclarations.push('const Utility: {};');
}

for (const interfaceKey of interfaceKeys) {
const alias = ` type ${interfaceKey} = Electron.${interfaceKey}`;
Expand Down

0 comments on commit 89617c3

Please sign in to comment.