From acc3c2faae76995ea05ef2faa641066450a982ae Mon Sep 17 00:00:00 2001 From: Alisue Date: Tue, 27 Feb 2024 10:25:58 +0900 Subject: [PATCH 1/4] :bug: 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. ``` --- metadata.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/metadata.ts b/metadata.ts index 1e12571..584173e 100644 --- a/metadata.ts +++ b/metadata.ts @@ -1,13 +1,11 @@ import type { Predicate } from "./is/type.ts"; import { inspect } from "./inspect.ts"; -const metadataKey = "__unknownutil_metadata"; - /** * A type that has metadata. */ export type WithMetadata = { - [metadataKey]: T; + __unknownutil_metadata: T; }; /** @@ -21,7 +19,7 @@ export type GetMetadata = T extends WithMetadata ? M : never; export function getMetadata(v: unknown): T | undefined { if (v == null) return undefined; // deno-lint-ignore no-explicit-any - return (v as any)[metadataKey]; + return (v as any).__unknownutil_metadata; } /** @@ -44,7 +42,7 @@ export function setPredicateFactoryMetadata< ): P & WithMetadata { let cachedName: string | undefined; return Object.defineProperties(pred, { - [metadataKey]: { + __unknownutil_metadata: { value: metadata, configurable: true, }, From fc3a0be444dab7539287a15308ae6fc1f20a0a64 Mon Sep 17 00:00:00 2001 From: Alisue Date: Tue, 27 Feb 2024 10:06:36 +0900 Subject: [PATCH 2/4] :coffee: Support JSR via @david/publish-on-tag --- .github/workflows/jsr.yml | 27 +++++++++++++++++++++++++++ deno.jsonc | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/jsr.yml diff --git a/.github/workflows/jsr.yml b/.github/workflows/jsr.yml new file mode 100644 index 0000000..2de3f3a --- /dev/null +++ b/.github/workflows/jsr.yml @@ -0,0 +1,27 @@ +name: jsr + +env: + DENO_VERSION: 1.x + +on: + push: + tags: + - "v*" + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: denoland/setup-deno@v1 + with: + deno-version: ${{ env.DENO_VERSION }} + - name: Publish + run: | + deno run -A jsr:@david/publish-on-tag@0.1.3 diff --git a/deno.jsonc b/deno.jsonc index 31fc387..320f2c3 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,4 +1,7 @@ { + "name": "@core/unknownutil", + "version": "0.0.0", + "exports": "./mod.ts", "lock": false, "imports": { "https://deno.land/x/unknownutil@$MODULE_VERSION/": "./" From 03984aec98e0a668a9e5b1fd81ffba57653af892 Mon Sep 17 00:00:00 2001 From: Alisue Date: Sat, 6 Apr 2024 11:49:12 +0900 Subject: [PATCH 3/4] :herb: Fix linting errors --- is/_deprecated.ts | 4 ++-- is/_deprecated_test.ts | 2 +- is/annotation_test.ts | 2 +- is/core_test.ts | 2 +- is/factory.ts | 2 +- is/factory_test.ts | 2 +- is/utility_test.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/is/_deprecated.ts b/is/_deprecated.ts index fa3b926..5bc7030 100644 --- a/is/_deprecated.ts +++ b/is/_deprecated.ts @@ -1,7 +1,7 @@ import type { UnionToIntersection } from "../_typeutil.ts"; import type { Predicate } from "./type.ts"; -import { type isObjectOf } from "./factory.ts"; -import { type GetMetadata, type WithMetadata } from "../metadata.ts"; +import type { isObjectOf } from "./factory.ts"; +import type { GetMetadata, WithMetadata } from "../metadata.ts"; import { isIntersectionOf, isUnionOf } from "./utility.ts"; type IsObjectOfMetadata = GetMetadata>; diff --git a/is/_deprecated_test.ts b/is/_deprecated_test.ts index 95e802d..8eae5af 100644 --- a/is/_deprecated_test.ts +++ b/is/_deprecated_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate, type PredicateType } from "./type.ts"; +import type { Predicate, PredicateType } from "./type.ts"; import { isBoolean, isNumber, isString } from "./core.ts"; import { isObjectOf } from "./factory.ts"; import is, { isAllOf, isOneOf } from "./_deprecated.ts"; diff --git a/is/annotation_test.ts b/is/annotation_test.ts index 7d9307d..ceeed47 100644 --- a/is/annotation_test.ts +++ b/is/annotation_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate } from "./type.ts"; +import type { Predicate } from "./type.ts"; import { isArray, isAsyncFunction, diff --git a/is/core_test.ts b/is/core_test.ts index 1e1dfa6..3b15eb9 100644 --- a/is/core_test.ts +++ b/is/core_test.ts @@ -3,7 +3,7 @@ import { assertStrictEquals, } from "https://deno.land/std@0.211.0/assert/mod.ts"; import { stringify } from "./_testutil.ts"; -import { type Predicate } from "./type.ts"; +import type { Predicate } from "./type.ts"; import is, { isAny, isArray, diff --git a/is/factory.ts b/is/factory.ts index aa5506f..a18c467 100644 --- a/is/factory.ts +++ b/is/factory.ts @@ -1,6 +1,6 @@ import type { FlatType } from "../_typeutil.ts"; import type { Predicate, PredicateType } from "./type.ts"; -import { isOptionalOf, isReadonlyOf } from "./annotation.ts"; +import { type isOptionalOf, isReadonlyOf } from "./annotation.ts"; import { isAny, isArray, diff --git a/is/factory_test.ts b/is/factory_test.ts index b31f491..5fea614 100644 --- a/is/factory_test.ts +++ b/is/factory_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate } from "./type.ts"; +import type { Predicate } from "./type.ts"; import { isOptionalOf } from "./annotation.ts"; import { isArray, diff --git a/is/utility_test.ts b/is/utility_test.ts index 11ff12e..dfff944 100644 --- a/is/utility_test.ts +++ b/is/utility_test.ts @@ -7,7 +7,7 @@ import { } from "https://deno.land/std@0.211.0/testing/snapshot.ts"; import { assertType } from "https://deno.land/std@0.211.0/testing/types.ts"; import { type Equal, stringify } from "./_testutil.ts"; -import { type Predicate, type PredicateType } from "./type.ts"; +import type { Predicate, PredicateType } from "./type.ts"; import { isOptionalOf } from "./annotation.ts"; import { isBoolean, isNumber, isString, isUndefined } from "./core.ts"; import { isObjectOf } from "./factory.ts"; From 024b8ddc70f229918054f36f3f604d548bf87b11 Mon Sep 17 00:00:00 2001 From: Alisue Date: Sat, 6 Apr 2024 12:02:34 +0900 Subject: [PATCH 4/4] :memo: Update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b60191f..1eebd51 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # unknownutil -[![npm](http://img.shields.io/badge/available%20on-npm-lightgrey.svg?logo=npm&logoColor=white)](https://www.npmjs.com/package/unknownutil) -[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/unknownutil) +[![jsr](https://img.shields.io/jsr/v/%40core/unknownutil?logo=javascript&logoColor=white)](https://jsr.io/@core/unknownutil) +[![npm](https://img.shields.io/npm/v/unknownutil?logo=npm&logoColor=white)](https://www.npmjs.com/package/unknownutil) +[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-unknownutil?logo=deno&label=denoland)](https://github.com/lambdalisue/deno-unknownutil/releases) [![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/unknownutil/mod.ts) -[![Test](https://github.com/lambdalisue/deno-unknownutil/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-unknownutil/actions?query=workflow%3ATest) -[![npm version](https://badge.fury.io/js/unknownutil.svg)](https://badge.fury.io/js/unknownutil) +[![test](https://github.com/lambdalisue/deno-unknownutil/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-unknownutil/actions?query=workflow%3ATest) [![codecov](https://codecov.io/github/lambdalisue/deno-unknownutil/graph/badge.svg?token=pfbLRGU5AM)](https://codecov.io/github/lambdalisue/deno-unknownutil) A utility pack for handling `unknown` type.