Skip to content

Commit 271e8bc

Browse files
committed
refactor: Improve type safety and remove unnecessary type annotation
1 parent 74137f0 commit 271e8bc

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function createParser(
9090
if (syntaxDefinition.baseSyntax) {
9191
syntaxDefinition = extendSyntaxDefinition(cssSyntaxDefinitions[syntaxDefinition.baseSyntax], syntaxDefinition);
9292
}
93-
93+
9494
// Apply additional features if specified
9595
if (features && features.length > 0) {
9696
for (const feature of features) {

src/syntax-definitions.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ export type PseudoClassType = Exclude<'NoArgument' | AstPseudoClassArgument['typ
44
export type PseudoElementType = Exclude<'NoArgument' | AstPseudoElementArgument['type'], 'Substitution'>;
55
export type CssLevel = 'css1' | 'css2' | 'css3' | 'selectors-3' | 'selectors-4' | 'latest' | 'progressive';
66

7-
/**
8-
* CSS Feature module name.
9-
* @example 'css-position-3'
10-
* @example 'css-scoping-1'
11-
*/
12-
export type CssFeature = string;
13-
147
/**
158
* CSS Selector Syntax Definition can be used to define custom CSS selector parsing rules.
169
*/
@@ -415,12 +408,12 @@ export const cssSyntaxDefinitions: Record<CssLevel, SyntaxDefinition> = {
415408
/**
416409
* CSS Feature modules with their syntax definitions.
417410
* These can be used to extend the parser with specific CSS features.
418-
*
411+
*
419412
* @example
420413
* // Using the css-position-3 feature
421414
* createParser({ features: ['css-position-3'] })
422415
*/
423-
export const cssFeatures: Record<string, SyntaxDefinition> = {
416+
export const cssFeatures = {
424417
'css-position-3': {
425418
pseudoClasses: {
426419
definitions: {
@@ -446,4 +439,11 @@ export const cssFeatures: Record<string, SyntaxDefinition> = {
446439
definitions: ['slotted']
447440
}
448441
}
449-
};
442+
} satisfies Record<string, SyntaxDefinition>;
443+
444+
/**
445+
* CSS Feature module name.
446+
* @example 'css-position-3'
447+
* @example 'css-scoping-1'
448+
*/
449+
export type CssFeature = keyof typeof cssFeatures;

0 commit comments

Comments
 (0)