Skip to content

Commit

Permalink
fix missing embed loc types (#378)
Browse files Browse the repository at this point in the history
closes #377
  • Loading branch information
bartveneman authored Dec 30, 2023
1 parent ab7e7b8 commit 5859e24
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function analyze(css, options = {}) {
let embedSize = 0
let embedTypes = {
total: 0,
/** @type {Map<string, {size: number, count: number}>} */
/** @type {Map<string, { size: number, count: number } & ({ __unstable__uniqueWithLocations?: undefined } | ({ offset: number, line: number, column: number, length: number }[])) }>} */
unique: new Map()
}

Expand Down Expand Up @@ -375,9 +375,13 @@ export function analyze(css, options = {}) {
embedSize += size

let loc = {
/** @type {number} */
line: node.loc.start.line,
/** @type {number} */
column: node.loc.start.column,
/** @type {number} */
offset: node.loc.start.offset,
/** @type {number} */
length: node.loc.end.offset - node.loc.start.offset,
}

Expand All @@ -390,14 +394,14 @@ export function analyze(css, options = {}) {
item.__unstable__uniqueWithLocations.push(loc)
}
} else {
let new_item = {
let item = {
count: 1,
size
}
if (useLocations) {
new_item.__unstable__uniqueWithLocations = [loc]
item.__unstable__uniqueWithLocations = [loc]
}
embedTypes.unique.set(type, new_item)
embedTypes.unique.set(type, item)
}

// @deprecated
Expand Down

0 comments on commit 5859e24

Please sign in to comment.