@travetto/registry
Advanced tools
Comparing version 5.0.0-rc.8 to 5.0.0-rc.9
{ | ||
"name": "@travetto/registry", | ||
"version": "5.0.0-rc.8", | ||
"version": "5.0.0-rc.9", | ||
"description": "Patterns and utilities for handling registration of metadata and functionality for run-time use", | ||
@@ -30,7 +30,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@travetto/runtime": "^5.0.0-rc.8" | ||
"@travetto/runtime": "^5.0.0-rc.9" | ||
}, | ||
"peerDependencies": { | ||
"@travetto/cli": "^5.0.0-rc.8", | ||
"@travetto/transformer": "^5.0.0-rc.5" | ||
"@travetto/cli": "^5.0.0-rc.9", | ||
"@travetto/transformer": "^5.0.0-rc.6" | ||
}, | ||
@@ -37,0 +37,0 @@ "peerDependenciesMeta": { |
@@ -65,4 +65,3 @@ import { Module } from 'node:module'; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return this.#modules.get(file)!.get() as T; | ||
return this.#modules.get(file)!.get<T>(); | ||
} | ||
@@ -69,0 +68,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { ConcreteClass } from '@travetto/runtime'; | ||
import { Any, castKey, castTo, classConstruct } from '@travetto/runtime'; | ||
@@ -17,4 +17,3 @@ const ProxyTargetⲐ = Symbol.for('@travetto/runtime:proxy-target'); | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export class RetargettingHandler<T> implements ProxyHandler<any> { | ||
export class RetargettingHandler<T> implements ProxyHandler<Any> { | ||
constructor(public target: T) { } | ||
@@ -39,14 +38,11 @@ | ||
apply(target: T, thisArg: T, argArray?: unknown[]): unknown { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return (this.target as unknown as Function).apply(this.target, argArray); | ||
return castTo<Function>(this.target).apply(this.target, argArray); | ||
} | ||
construct(target: T, argArray: unknown[], newTarget?: unknown): object { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return new (this.target as unknown as ConcreteClass)(...argArray); | ||
return classConstruct(castTo(this.target), argArray); | ||
} | ||
setPrototypeOf(target: T, v: unknown): boolean { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return Object.setPrototypeOf(this.target, v as Record<string, unknown>); | ||
return Object.setPrototypeOf(this.target, castTo(v)); | ||
} | ||
@@ -58,9 +54,7 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
get(target: T, prop: PropertyKey, receiver: unknown): any { | ||
get(target: T, prop: PropertyKey, receiver: unknown): Any { | ||
if (prop === ProxyTargetⲐ) { | ||
return this.target; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
let ret = this.target[prop as keyof T]; | ||
let ret = this.target[castKey<T>(prop)]; | ||
if (isFunction(ret) && !/^class\s/.test(Function.prototype.toString.call(ret))) { | ||
@@ -74,9 +68,7 @@ // Bind class members to class instance instead of proxy propagating | ||
has(target: T, prop: PropertyKey): boolean { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return (this.target as Object).hasOwnProperty(prop); | ||
return castTo<object>(this.target).hasOwnProperty(prop); | ||
} | ||
set(target: T, prop: PropertyKey, value: unknown): boolean { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions | ||
this.target[prop as keyof T] = value as any; | ||
this.target[castKey<T>(prop)] = castTo(value); | ||
return true; | ||
@@ -93,4 +85,3 @@ } | ||
deleteProperty(target: T, p: PropertyKey): boolean { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return delete this.target[p as keyof T]; | ||
return delete this.target[castKey<T>(p)]; | ||
} | ||
@@ -115,4 +106,3 @@ | ||
static unwrap<U>(el: U): U { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions | ||
return (el ? ((el as any)[ProxyTargetⲐ] ?? el) : el) as U; | ||
return castTo<{ [ProxyTargetⲐ]: U }>(el)?.[ProxyTargetⲐ] ?? el; | ||
} | ||
@@ -125,4 +115,3 @@ | ||
this.#handler = new RetargettingHandler(initial); | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
this.#instance = new Proxy({}, this.#handler as ProxyHandler<object>); | ||
this.#instance = new Proxy({}, castTo(this.#handler)); | ||
} | ||
@@ -140,6 +129,5 @@ | ||
get(): T { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return this.#instance as T; | ||
get<V extends T>(): V { | ||
return castTo(this.#instance); | ||
} | ||
} |
@@ -110,4 +110,3 @@ import { Class } from '@travetto/runtime'; | ||
getParentClass(cls: Class): Class | null { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
const parent = Object.getPrototypeOf(cls) as Class; | ||
const parent: Class = Object.getPrototypeOf(cls); | ||
return parent.name && parent !== Object ? parent : null; | ||
@@ -114,0 +113,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33215
818