Skip to content

Commit

Permalink
fix: relax isTemplateLiteral check for tslib compat
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Dec 9, 2024
1 parent f93fdf4 commit 898f0d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T, E>(target: T, ...extras: E[]): T =>
Expand Down
2 changes: 2 additions & 0 deletions src/test/ts/util.test.ts
Original file line number Diff line number Diff line change
@@ -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()', () => {
Expand All @@ -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'))
Expand Down

0 comments on commit 898f0d0

Please sign in to comment.