From 7f3fc2167576f228f8183568eb52b077160e8d65 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Wed, 8 Mar 2023 09:46:45 -0800 Subject: [PATCH] fix(core): Use Symbol.for to instantiate shared symbols (#3087) --- packages/adapter-commons/src/service.ts | 2 +- packages/commons/src/index.ts | 2 +- packages/knex/src/error-handler.ts | 2 +- packages/schema/src/hooks/resolve.ts | 2 +- packages/schema/src/resolver.ts | 2 +- packages/transport-commons/src/channels/mixins.ts | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/adapter-commons/src/service.ts b/packages/adapter-commons/src/service.ts index c007a2e685..cbaeb38718 100644 --- a/packages/adapter-commons/src/service.ts +++ b/packages/adapter-commons/src/service.ts @@ -7,7 +7,7 @@ import { } from './declarations' import { filterQuery } from './query' -export const VALIDATED = Symbol('@feathersjs/adapter/sanitized') +export const VALIDATED = Symbol.for('@feathersjs/adapter/sanitized') const alwaysMulti: { [key: string]: boolean } = { find: true, diff --git a/packages/commons/src/index.ts b/packages/commons/src/index.ts index c13b82adac..9455252384 100644 --- a/packages/commons/src/index.ts +++ b/packages/commons/src/index.ts @@ -96,7 +96,7 @@ export function isPromise(result: any) { } export function createSymbol(name: string) { - return typeof Symbol !== 'undefined' ? Symbol(name) : name + return typeof Symbol !== 'undefined' ? Symbol.for(name) : name } export * from './debug' diff --git a/packages/knex/src/error-handler.ts b/packages/knex/src/error-handler.ts index daf90d8379..6f4e7dcdc7 100644 --- a/packages/knex/src/error-handler.ts +++ b/packages/knex/src/error-handler.ts @@ -1,6 +1,6 @@ import { errors } from '@feathersjs/errors' -export const ERROR = Symbol('@feathersjs/knex/error') +export const ERROR = Symbol.for('@feathersjs/knex/error') export function errorHandler(error: any) { const { message } = error diff --git a/packages/schema/src/hooks/resolve.ts b/packages/schema/src/hooks/resolve.ts index 60d60c1b96..0e9a35a506 100644 --- a/packages/schema/src/hooks/resolve.ts +++ b/packages/schema/src/hooks/resolve.ts @@ -110,7 +110,7 @@ export const resolveResult = (...resolvers: Resolver { if (typeof value === 'object' && value !== null) { diff --git a/packages/schema/src/resolver.ts b/packages/schema/src/resolver.ts index d8c617c139..928bef4971 100644 --- a/packages/schema/src/resolver.ts +++ b/packages/schema/src/resolver.ts @@ -14,7 +14,7 @@ export type VirtualResolver = ( status: ResolverStatus ) => Promise -export const IS_VIRTUAL = Symbol('@feathersjs/schema/virtual') +export const IS_VIRTUAL = Symbol.for('@feathersjs/schema/virtual') /** * Create a resolver for a virtual property. A virtual property is a property that diff --git a/packages/transport-commons/src/channels/mixins.ts b/packages/transport-commons/src/channels/mixins.ts index e0f52b15c8..16188c99f2 100644 --- a/packages/transport-commons/src/channels/mixins.ts +++ b/packages/transport-commons/src/channels/mixins.ts @@ -5,9 +5,9 @@ import { Channel } from './channel/base' import { CombinedChannel } from './channel/combined' const debug = createDebug('@feathersjs/transport-commons/channels/mixins') -const PUBLISHERS = Symbol('@feathersjs/transport-commons/publishers') -const CHANNELS = Symbol('@feathersjs/transport-commons/channels') -const ALL_EVENTS = Symbol('@feathersjs/transport-commons/all-events') +const PUBLISHERS = Symbol.for('@feathersjs/transport-commons/publishers') +const CHANNELS = Symbol.for('@feathersjs/transport-commons/channels') +const ALL_EVENTS = Symbol.for('@feathersjs/transport-commons/all-events') export const keys = { PUBLISHERS: PUBLISHERS as typeof PUBLISHERS,