Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow primitives in NodeJS.Process modifications #107

Merged
merged 1 commit into from Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/module-declaration.js
Expand Up @@ -125,7 +125,8 @@ const generateModuleDeclaration = (module, index, API) => {
if (moduleMethod.returns) {
returnType = moduleMethod.returns
// Account for methods on the process module that return a custom type/structure, we need to reference the Electron namespace to use these types
if (module.name === 'process' && moduleMethod.returns.type !== 'Object') {
if (module.name === 'process' && moduleMethod.returns.type !== 'Object' &&
typeof moduleMethod.returns.type === 'string') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking for my own understanding, could you explain what this addition does wrt the Number | null documentation change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously all modifications to the process API in nodejs used complex structures as the return values. These lived in the "Electron" namespace so we blanket prefixed all the type names here so that the types were referenced correctly.

This PR adds "number" and "null" as return types which are primitives and don't exist in the electron namespace. Primitives are still type objects at this point in the code not string names. So we can just typeof check to see if we should prefix with "Electron" or not

returnType = `Electron.${moduleMethod.returns.type}`
}
}
Expand Down