From cbfbe788c42e37dc444153ae862d2d40ddccd48f Mon Sep 17 00:00:00 2001 From: auvred Date: Fri, 8 Aug 2025 12:26:35 +0300 Subject: [PATCH] Fix types for Case_Folding and Special_Casing --- scripts/utils.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/utils.js b/scripts/utils.js index 1c84a49..a305959 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -162,6 +162,8 @@ const writeFiles = function(options) { // Save the data to a file let codePointsExports = `require('./ranges.js').flatMap(r=>Array.from(r.keys()))`; let symbolsExports = `require('./ranges.js').flatMap(r=>Array.from(r.values()))`; + let codePointsType = 'number[]'; + let symbolsType = 'string[]'; if (!isCaseFoldingOrMapping) { const encodedRanges = codePoints instanceof regenerate ? encodeRegenerate(codePoints) : encodeRanges(codePoints); fs.writeFileSync( @@ -198,6 +200,12 @@ const writeFiles = function(options) { } codePointsExports = codePoints.size < 10 ? jsesc(codePoints) : gzipInline(codePoints); symbolsExports = codePoints.size < 10 ? jsesc(symbols) : gzipInline(symbols); + if ((type === 'Case_Folding' && item === 'F') || type === 'Special_Casing') { + codePointsType = 'Map'; + } else { + codePointsType = 'Map'; + } + symbolsType = 'Map'; } fs.writeFileSync( path.resolve(dir, 'code-points.js'), @@ -205,7 +213,7 @@ const writeFiles = function(options) { ); fs.writeFileSync( path.resolve(dir, 'code-points.d.ts'), - `declare const codePoints: number[];\nexport = codePoints;` + `declare const codePoints: ${ codePointsType };\nexport = codePoints;` ); fs.writeFileSync( path.resolve(dir, 'symbols.js'), @@ -213,7 +221,7 @@ const writeFiles = function(options) { ); fs.writeFileSync( path.resolve(dir, 'symbols.d.ts'), - `declare const symbols: string[];\nexport = symbols;` + `declare const symbols: ${ symbolsType };\nexport = symbols;` ); }); if (options.type == 'Bidi_Mirroring_Glyph') {