Skip to content

Commit a5acf24

Browse files
authored
Fix types for Case_Folding and Special_Casing (#92)
1 parent c7fb387 commit a5acf24

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/utils.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ const writeFiles = function(options) {
162162
// Save the data to a file
163163
let codePointsExports = `require('./ranges.js').flatMap(r=>Array.from(r.keys()))`;
164164
let symbolsExports = `require('./ranges.js').flatMap(r=>Array.from(r.values()))`;
165+
let codePointsType = 'number[]';
166+
let symbolsType = 'string[]';
165167
if (!isCaseFoldingOrMapping) {
166168
const encodedRanges = codePoints instanceof regenerate ? encodeRegenerate(codePoints) : encodeRanges(codePoints);
167169
fs.writeFileSync(
@@ -198,22 +200,28 @@ const writeFiles = function(options) {
198200
}
199201
codePointsExports = codePoints.size < 10 ? jsesc(codePoints) : gzipInline(codePoints);
200202
symbolsExports = codePoints.size < 10 ? jsesc(symbols) : gzipInline(symbols);
203+
if ((type === 'Case_Folding' && item === 'F') || type === 'Special_Casing') {
204+
codePointsType = 'Map<number, number[]>';
205+
} else {
206+
codePointsType = 'Map<number, number>';
207+
}
208+
symbolsType = 'Map<string, string>';
201209
}
202210
fs.writeFileSync(
203211
path.resolve(dir, 'code-points.js'),
204212
`module.exports=${ codePointsExports }`
205213
);
206214
fs.writeFileSync(
207215
path.resolve(dir, 'code-points.d.ts'),
208-
`declare const codePoints: number[];\nexport = codePoints;`
216+
`declare const codePoints: ${ codePointsType };\nexport = codePoints;`
209217
);
210218
fs.writeFileSync(
211219
path.resolve(dir, 'symbols.js'),
212220
`module.exports=${ symbolsExports }`
213221
);
214222
fs.writeFileSync(
215223
path.resolve(dir, 'symbols.d.ts'),
216-
`declare const symbols: string[];\nexport = symbols;`
224+
`declare const symbols: ${ symbolsType };\nexport = symbols;`
217225
);
218226
});
219227
if (options.type == 'Bidi_Mirroring_Glyph') {

0 commit comments

Comments
 (0)