From fd75951df0feca45034c428570e2330f50ba3a62 Mon Sep 17 00:00:00 2001 From: rawpixel-vincent Date: Sat, 30 Mar 2024 02:04:16 +0700 Subject: [PATCH] update enum type --- package-lock.json | 4 ++-- package.json | 2 +- stringList.test.js | 11 +++++++++-- types/list.d.ts | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 02f38e9..2ff7cbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "string-literal-list", - "version": "1.20.0", + "version": "1.21.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "string-literal-list", - "version": "1.20.0", + "version": "1.21.0", "license": "MIT", "devDependencies": { "@types/node": "latest", diff --git a/package.json b/package.json index 884e4da..f684e8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "string-literal-list", - "version": "1.20.0", + "version": "1.21.0", "description": "an array for string literal", "main": "stringList.cjs", "module": "stringList.js", diff --git a/stringList.test.js b/stringList.test.js index 50cc88c..609e2d5 100644 --- a/stringList.test.js +++ b/stringList.test.js @@ -18,6 +18,13 @@ import mutableMin from './stringList.min.js'; import strictMin from './strict.min.js'; +/** @type {typeof import('./stringList.js')['sl']} */ +// @ts-expect-error +const mutableMinStringListCjs = mutableMin.stringList; +/** @type {typeof import('./strict.js')['sl']} */ +// @ts-expect-error +const strictMinStringListCjs = strictMin.stringList; + import { createRequire } from 'module'; const require = createRequire(import.meta.url); /** @type {typeof import('./stringList.js')['sl']} */ @@ -47,11 +54,11 @@ const functions = [ }, { type: 'mutableMin', - stringList: mutableMin.stringList, + stringList: mutableMinStringListCjs, }, { type: 'immutableMin', - stringList: strictMin.stringList, + stringList: strictMinStringListCjs, }, ]; diff --git a/types/list.d.ts b/types/list.d.ts index 500488e..1a2558c 100644 --- a/types/list.d.ts +++ b/types/list.d.ts @@ -219,7 +219,7 @@ export interface IStringList< // Readonly overrides readonly length: [Unsorted] extends [true] ? number : Tuple['length']; readonly [n: number]: Tuple[number] | undefined; - readonly enum: { [P in Tuple[number]]: P }; + readonly enum: { [P in Tuple[number]]: P } & { [P: string]: Tuple[number] }; // Supported Methods at(n: number): Tuple[number] | undefined;