Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/destructure-box-shadow.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect, describe } from 'vitest'
import { destructure_box_shadow } from './destructure-box-shadow.js'
import { ColorValue, EXTENSION_AUTHORED_AS } from './types.js'
import type { ColorValue } from './types.js'
import { color_to_token } from './colors.js'

function create_px_length(value: number): { value: number, unit: string } {
Expand Down
7 changes: 7 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ describe('css_to_tokens', () => {
`)
expect(actual.color).toEqual({})
})

test('extensions[css-properties] does not yield a type error', () => {
let actual = css_to_tokens('a { color: green; }')
// Not so much interested in the test result, more looking that this isn't giving a type error
let properties = actual.color['green-5e0cf03']!['$extensions'][EXTENSION_CSS_PROPERTIES]
expect(properties).toEqual(['color'])
})
})

describe('font sizes', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type ItemsPerContext = Record<string, {
type TokenID = string

type Tokens = {
color: Record<TokenID, ColorToken | UnparsedToken>
color: Record<TokenID, ColorToken>
font_size: Record<TokenID, UnparsedToken | DimensionToken>
font_family: Record<TokenID, FontFamilyToken>
line_height: Record<TokenID, UnparsedToken | DimensionToken | NumberToken>
Expand Down Expand Up @@ -86,7 +86,7 @@ function get_count(collection_item: number | CssLocation[]) {
export function analysis_to_tokens(analysis: CssAnalysis): Tokens {
return {
color: (() => {
let colors = Object.create(null) as Record<TokenID, ColorToken | UnparsedToken>
let colors = Object.create(null) as Record<TokenID, ColorToken>
let unique = get_unique(analysis.values.colors)
let color_groups = group_colors(unique)

Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@
],
"exclude": [
"node_modules",
"src/**/*.test.ts"
]
}