@@ -63,6 +63,58 @@ describe('extractDataAttrs', () => {
6363 expect ( result ! . attrs ) . toHaveLength ( 1 ) ;
6464 } ) ;
6565
66+ it ( 'extracts from {Name}DataAttrs with as const satisfies' , ( ) => {
67+ const code = `
68+ type StateAttrMap<State> = { [Key in keyof State]?: string };
69+ interface MockComponentState {
70+ active: boolean;
71+ }
72+
73+ export const MockComponentDataAttrs = {
74+ active: 'data-active',
75+ } as const satisfies StateAttrMap<MockComponentState>;
76+ ` ;
77+ const program = createTestProgram ( code ) ;
78+ const result = extractDataAttrs ( 'test.ts' , program , 'MockComponent' ) ;
79+
80+ expect ( result ) . not . toBeNull ( ) ;
81+ expect ( result ! . attrs ) . toHaveLength ( 1 ) ;
82+ expect ( result ! . attrs [ 0 ] ! . name ) . toBe ( 'data-active' ) ;
83+ } ) ;
84+
85+ it ( 'extracts from {Name}DataAttrs with satisfies expression' , ( ) => {
86+ const code = `
87+ export const MockComponentDataAttrs = ({
88+ active: 'data-active',
89+ }) satisfies Record<string, string>;
90+ ` ;
91+ const program = createTestProgram ( code ) ;
92+ const result = extractDataAttrs ( 'test.ts' , program , 'MockComponent' ) ;
93+
94+ expect ( result ) . not . toBeNull ( ) ;
95+ expect ( result ! . attrs ) . toHaveLength ( 1 ) ;
96+ expect ( result ! . attrs [ 0 ] ! . name ) . toBe ( 'data-active' ) ;
97+ } ) ;
98+
99+ it ( 'extracts JSDoc comments for properties wrapped with satisfies' , ( ) => {
100+ const code = `
101+ type StateAttrMap<State> = { [Key in keyof State]?: string };
102+ interface MockComponentState {
103+ active: boolean;
104+ }
105+
106+ export const MockComponentDataAttrs = {
107+ /** Present when the component is active. */
108+ active: 'data-active',
109+ } as const satisfies StateAttrMap<MockComponentState>;
110+ ` ;
111+ const program = createTestProgram ( code ) ;
112+ const result = extractDataAttrs ( 'test.ts' , program , 'MockComponent' ) ;
113+
114+ expect ( result ) . not . toBeNull ( ) ;
115+ expect ( result ! . attrs [ 0 ] ! . description ) . toBe ( 'Present when the component is active.' ) ;
116+ } ) ;
117+
66118 it ( 'returns null when constant not found' , ( ) => {
67119 const code = `
68120 export const OtherConstant = {
0 commit comments