From 2fc581ffa3ec1b7ae81b9c197987ed9f61258fec Mon Sep 17 00:00:00 2001 From: David Blass Date: Fri, 12 Jan 2024 17:18:29 -0500 Subject: [PATCH] fix: don't freeze definitions for compatibility with sass (#901) --- README.md | 98 +++++++++---------- dev/configs/.changeset/beige-schools-guess.md | 5 + src/scopes/cache.ts | 9 -- src/scopes/scope.ts | 19 ++-- 4 files changed, 58 insertions(+), 73 deletions(-) create mode 100644 dev/configs/.changeset/beige-schools-guess.md diff --git a/README.md b/README.md index c16d5aebe7..b7cd975eeb 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Check out [how it works](#how), [try it in-browser](https://arktype.io/docs/#you (or whatever package manager you prefer)
-Our types are tested in [strict-mode](https://www.typescriptlang.org/tsconfig#strict) with TypeScript versions `4.8`, `4.9`, and `5.0`. +Our types are tested in [strict-mode](https://www.typescriptlang.org/tsconfig#strict) with TypeScript version `4.8` or greater. _Our APIs have mostly stabilized, but details may still change during the alpha/beta stages of our 1.0 release. If you have suggestions that may require a breaking change, now is the time to let us know!_ ⛵ @@ -259,15 +259,12 @@ If the project has been useful to you and you are in a financial position to do Otherwise, consider sending me an email (david@arktype.io) or [message me on Discord](https://arktype.io/discord) to let me know you're a fan of ArkType. Either would make my day! -### Current Sponsors 🥰 +### ArkSponsors ⛵ - - - + + +## Sponsors 🥰 + +
fubhy sam-goodwintmmthomasballingerjacksteamdev
@@ -284,6 +281,19 @@ Otherwise, consider sending me an email (david@arktype.io) or [message me on Dis src="https://avatars.githubusercontent.com/u/38672686" />
+ + + + + + + + - + + + - - - - - - - - - - - - - + + + + +
tmmjacksteamdevneodonmewhhahacodeandcats
- - + + + + + +
neodonmewhhahacodeandcatsxrexyTimeraa
- - - - - - - - - -
Timeraa
+ +
diff --git a/dev/configs/.changeset/beige-schools-guess.md b/dev/configs/.changeset/beige-schools-guess.md new file mode 100644 index 0000000000..2ac7144b3d --- /dev/null +++ b/dev/configs/.changeset/beige-schools-guess.md @@ -0,0 +1,5 @@ +--- +"arktype": patch +--- + +fix: don't freeze definitions for compatibility with sass diff --git a/src/scopes/cache.ts b/src/scopes/cache.ts index da4a73a578..995be0814e 100644 --- a/src/scopes/cache.ts +++ b/src/scopes/cache.ts @@ -1,5 +1,3 @@ -import { deepFreeze } from "../utils/freeze.js" - export class Cache { protected cache: { [name in string]?: item } = {} @@ -20,10 +18,3 @@ export class Cache { return item } } - -export class FreezingCache extends Cache { - override set(name: string, item: item) { - this.cache[name] = deepFreeze(item) as item - return item - } -} diff --git a/src/scopes/scope.ts b/src/scopes/scope.ts index a17ec260ae..584236eca3 100644 --- a/src/scopes/scope.ts +++ b/src/scopes/scope.ts @@ -15,7 +15,6 @@ import type { import { compileProblemWriters } from "../traverse/problems.js" import { chainableNoOpProxy } from "../utils/chainableNoOpProxy.js" import { throwInternalError, throwParseError } from "../utils/errors.js" -import { deepFreeze } from "../utils/freeze.js" import type { Dict, error, @@ -28,7 +27,7 @@ import { hasKeys } from "../utils/generics.js" import { Path } from "../utils/paths.js" import type { stringifyUnion } from "../utils/unionToTuple.js" import type { PrecompiledDefaults } from "./ark.js" -import { Cache, FreezingCache } from "./cache.js" +import { Cache } from "./cache.js" import type { Expressions } from "./expressions.js" import type { AnonymousTypeName, @@ -182,7 +181,7 @@ export const isConfigTuple = (def: unknown): def is ConfigTuple => export class Scope { name: string config: ScopeConfig - parseCache = new FreezingCache() + parseCache = new Cache() #resolutions = new Cache() #exports = new Cache() @@ -307,8 +306,8 @@ export class Scope { seen.push(node) node = this.#resolveRecurse(node, "throw", seen).node } - t.node = deepFreeze(node) - t.flat = deepFreeze(flattenType(t)) + t.node = node + t.flat = flattenType(t) return t } @@ -360,12 +359,10 @@ export class Scope { const t = initializeType("λtype", def, config, this) const ctx = this.#initializeContext(t) const root = parseDefinition(def, ctx) - t.node = deepFreeze( - hasKeys(config) - ? { config, node: this.resolveTypeNode(root) } - : root - ) - t.flat = deepFreeze(flattenType(t)) + t.node = hasKeys(config) + ? { config, node: this.resolveTypeNode(root) } + : root + t.flat = flattenType(t) return t }, { from: this.expressions.node }