Skip to content

Commit

Permalink
improve types for CssLocations
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Veneman committed Oct 29, 2023
1 parent d01bb75 commit cc4b60f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/collection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class Collection {
constructor({ useLocations = false }) {
/** @type {Map<string, Array<Number>>} */
/** @type {Map<string, number[]>} */
this._items = new Map()
this._total = 0
/** @type {number[]} */
Expand Down Expand Up @@ -44,6 +44,15 @@ export class Collection {
return this._total
}

/**
* @typedef CssLocation
* @property {number} line
* @property {number} column
* @property {number} offset
* @property {number} length
*
* @returns {{ total: number; totalUnique: number; uniquenessRatio: number; unique: Record<string, number>; __unstable__uniqueWithLocations: Record<string, CssLocation[]>}}
*/
count() {
let uniqueWithLocations = new Map()
let unique = {}
Expand Down
2 changes: 1 addition & 1 deletion src/context-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ContextCollection {
* @type {Map<string, {
* total: number,
* totalUnique: number,
* unique: {[k: string]: number},
* unique: Record<string, number>,
* uniquenessRatio: number
* }>}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function analyze(css, options = {}) {

// Atrules
let totalAtRules = 0
/** @type {{[property: string]: string}[]} */
/** @type {Record<string: string>}[]} */
let fontfaces = []
let layers = new Collection({ useLocations })
let imports = new Collection({ useLocations })
Expand Down

0 comments on commit cc4b60f

Please sign in to comment.