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

Use cross-environment globalThis to access the global object. #416

Merged
merged 2 commits into from
Feb 26, 2023

Conversation

T-Hugs
Copy link
Contributor

@T-Hugs T-Hugs commented Feb 26, 2023

Summary of changes

Prefers using globalThis to access the global object, which is standard across node and browser environments. I'm not sure what versions of browsers/node Deepkit is obligated to support, so we may be able to drop the envGlobal variable and just go with globalThis everywhere.

Relinquishment of Rights

Please mark following checkbox to confirm that you relinquish all rights of your changes:

  • I waive and relinquish all rights regarding this changes (including code, text, and images) to Deepkit UG (limited), Germany. This changes (including code, text, and images) are under MIT license without name attribution, copyright notice, and permission notice requirement.

@@ -347,7 +353,7 @@ function serialize(type: Type, state: SerializerState): SerializedTypeReference
}

const classType = getClassName(type.classType);
const globalObject: boolean = global && (global as any)[classType] === type.classType;
const globalObject: boolean = envGlobal && (envGlobal as any)[classType] === type.classType;
Copy link
Member

Choose a reason for hiding this comment

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

can we not just define const envGlobal: any = ... and then omit this type cast?

@marcj marcj merged commit 7af681b into deepkit:master Feb 26, 2023
@marcj
Copy link
Member

marcj commented Feb 26, 2023

Cool, thank you @T-Hugs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants