Skip to content

Commit 5859e24

Browse files
authored
fix missing embed loc types (#378)
closes #377
1 parent ab7e7b8 commit 5859e24

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function analyze(css, options = {}) {
7777
let embedSize = 0
7878
let embedTypes = {
7979
total: 0,
80-
/** @type {Map<string, {size: number, count: number}>} */
80+
/** @type {Map<string, { size: number, count: number } & ({ __unstable__uniqueWithLocations?: undefined } | ({ offset: number, line: number, column: number, length: number }[])) }>} */
8181
unique: new Map()
8282
}
8383

@@ -375,9 +375,13 @@ export function analyze(css, options = {}) {
375375
embedSize += size
376376

377377
let loc = {
378+
/** @type {number} */
378379
line: node.loc.start.line,
380+
/** @type {number} */
379381
column: node.loc.start.column,
382+
/** @type {number} */
380383
offset: node.loc.start.offset,
384+
/** @type {number} */
381385
length: node.loc.end.offset - node.loc.start.offset,
382386
}
383387

@@ -390,14 +394,14 @@ export function analyze(css, options = {}) {
390394
item.__unstable__uniqueWithLocations.push(loc)
391395
}
392396
} else {
393-
let new_item = {
397+
let item = {
394398
count: 1,
395399
size
396400
}
397401
if (useLocations) {
398-
new_item.__unstable__uniqueWithLocations = [loc]
402+
item.__unstable__uniqueWithLocations = [loc]
399403
}
400-
embedTypes.unique.set(type, new_item)
404+
embedTypes.unique.set(type, item)
401405
}
402406

403407
// @deprecated

0 commit comments

Comments
 (0)