From 898f0d03f92b8c60ed6858277f02cf3c8d340f58 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Mon, 9 Dec 2024 23:25:16 +0300 Subject: [PATCH] fix: relax `isTemplateLiteral` check for tslib compat https://github.com/microsoft/tslib/pull/277 --- package-lock.json | 10 ++++++---- package.json | 1 + src/main/ts/util.ts | 2 +- src/test/ts/util.test.ts | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 95f42f7..89ca96a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "jsr": "^0.13.2", "minimist": "^1.2.8", "ts-node": "^10.9.2", + "tslib": "^2.8.1", "typedoc": "^0.27.2", "typescript": "^5.7.2" } @@ -8176,10 +8177,11 @@ } }, "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", - "dev": true + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" }, "node_modules/type-check": { "version": "0.4.0", diff --git a/package.json b/package.json index 138278c..87f776f 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "jsr": "^0.13.2", "minimist": "^1.2.8", "ts-node": "^10.9.2", + "tslib": "^2.8.1", "typedoc": "^0.27.2", "typescript": "^5.7.2" } diff --git a/src/main/ts/util.ts b/src/main/ts/util.ts index 77efc97..1c698e5 100644 --- a/src/main/ts/util.ts +++ b/src/main/ts/util.ts @@ -38,7 +38,7 @@ export const isStringLiteral = ( ): pieces is TemplateStringsArray => pieces?.length > 0 && pieces.raw?.length === pieces.length && - Object.isFrozen(pieces) && + // Object.isFrozen(pieces) && rest.length + 1 === pieces.length export const assign = (target: T, ...extras: E[]): T => diff --git a/src/test/ts/util.test.ts b/src/test/ts/util.test.ts index 94df44d..177e7a1 100644 --- a/src/test/ts/util.test.ts +++ b/src/test/ts/util.test.ts @@ -1,6 +1,7 @@ import * as assert from 'node:assert' import {describe, it, test} from 'node:test' import { assign, isStringLiteral } from '../../main/ts/util.js' +import tslib from 'tslib' describe('util', () => { it('assign()', () => { @@ -13,6 +14,7 @@ describe('util', () => { assert.ok(isStringLiteral``) assert.ok(isStringLiteral`foo`) assert.ok(isStringLiteral`foo ${bar}`) + assert.ok(isStringLiteral(tslib.__makeTemplateObject(["git pull --tags --force ", " ", ""], ["git pull --tags --force ", " ", ""]), 'foo', 'bar')) assert.ok(!isStringLiteral('')) assert.ok(!isStringLiteral('foo'))