Skip to content

Commit acc3c2f

Browse files
committed
🐛 Remove slow-types not allowd in JSR
JSR does not allow slow types. See https://jsr.io/docs/about-slow-types ``` error: TS1170 [ERROR]: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. [metadataKey]: T; ~~~~~~~~~~~~~ at file:///Users/alisue/ghq/github.com/lambdalisue/deno-unknownutil/metadata.ts:9:26 TS2304 [ERROR]: Cannot find name 'metadataKey'. [metadataKey]: T; ~~~~~~~~~~~ at file:///Users/alisue/ghq/github.com/lambdalisue/deno-unknownutil/metadata.ts:10:4 Found 2 errors. ```
1 parent a4b91de commit acc3c2f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

metadata.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import type { Predicate } from "./is/type.ts";
22
import { inspect } from "./inspect.ts";
33

4-
const metadataKey = "__unknownutil_metadata";
5-
64
/**
75
* A type that has metadata.
86
*/
97
export type WithMetadata<T> = {
10-
[metadataKey]: T;
8+
__unknownutil_metadata: T;
119
};
1210

1311
/**
@@ -21,7 +19,7 @@ export type GetMetadata<T> = T extends WithMetadata<infer M> ? M : never;
2119
export function getMetadata<T>(v: unknown): T | undefined {
2220
if (v == null) return undefined;
2321
// deno-lint-ignore no-explicit-any
24-
return (v as any)[metadataKey];
22+
return (v as any).__unknownutil_metadata;
2523
}
2624

2725
/**
@@ -44,7 +42,7 @@ export function setPredicateFactoryMetadata<
4442
): P & WithMetadata<M> {
4543
let cachedName: string | undefined;
4644
return Object.defineProperties(pred, {
47-
[metadataKey]: {
45+
__unknownutil_metadata: {
4846
value: metadata,
4947
configurable: true,
5048
},

0 commit comments

Comments
 (0)