@@ -14,9 +14,9 @@ describe('Components', () => {
1414
1515 for ( const id of getComponentIds ( ) ) {
1616 const proto = await getComponent ( id ) . catch ( noop ) ;
17- const require = new Set ( toArray ( proto ?. require ) . map ( p => p . id ) ) ;
17+ const require = new Set ( toArray ( /** @type any */ ( proto ) ?. require ) . map ( p => p . id ) ) ;
1818
19- forEach ( proto ?. optional , opt => {
19+ forEach ( /** @type any */ ( proto ?. optional ) , opt => {
2020 if ( require . has ( opt ) ) {
2121 assert . fail (
2222 `The optional dependency ${ opt } is redundant because ${ id } already requires it. Remove the optional dependency.`
@@ -47,7 +47,8 @@ describe('Components', () => {
4747 for ( const id of getComponentIds ( ) ) {
4848 const proto = await getComponent ( id ) . catch ( noop ) ;
4949 add ( id , 'a component id' ) ;
50- forEach ( proto ?. alias , a => add ( a , `an alias of ${ id } ` ) ) ;
50+ forEach ( /** @type {string | string[] | null | undefined } */ ( proto ?. alias ) , a =>
51+ add ( a , `an alias of ${ id } ` ) ) ;
5152 }
5253 } ) ;
5354} ) ;
@@ -74,15 +75,22 @@ describe('components.json', () => {
7475 }
7576
7677 for ( const id in entries ) {
77- consumeFn ( entries [ id ] , id , entries ) ;
78+ consumeFn ( entries [ id ] , id , /** @type { Record<string, ComponentEntry> } */ ( entries ) ) ;
7879 }
7980 }
8081
8182 describe ( '- should have valid alias titles' , ( ) => {
8283 for ( const lang of getLanguageIds ( ) ) {
8384 it ( `- ${ lang } should have all alias titles registered as alias` , async ( ) => {
84- const aliases = new Set ( toArray ( ( await getComponent ( lang ) ) . alias ) ) ;
85- const aliasTitles = components . languages [ lang ] ?. aliasTitles ?? { } ;
85+ const aliases = new Set (
86+ toArray (
87+ /** @type {string | string[] | null | undefined } */ (
88+ ( await getComponent ( lang ) ) . alias
89+ )
90+ )
91+ ) ;
92+ const aliasTitles =
93+ /** @type {ComponentEntry } */ ( components . languages [ lang ] ) ?. aliasTitles ?? { } ;
8694
8795 Object . keys ( aliasTitles ) . forEach ( id => {
8896 if ( ! aliases . has ( id ) ) {
@@ -103,7 +111,7 @@ describe('components.json', () => {
103111 . map ( key => {
104112 return {
105113 id : key ,
106- title : components . languages [ key ] . title ,
114+ title : /** @type { ComponentEntry } */ ( components . languages [ key ] ) . title ,
107115 } ;
108116 } ) ;
109117
@@ -119,12 +127,16 @@ describe('components.json', () => {
119127 }
120128
121129 const sorted = [ ...languages ] . sort ( ( a , b ) => {
122- const comp = transformTitle ( a . title ) . localeCompare ( transformTitle ( b . title ) ) ;
130+ const comp = transformTitle ( /** @type {string } */ ( a . title ) ) . localeCompare (
131+ transformTitle ( /** @type {string } */ ( b . title ) )
132+ ) ;
123133 if ( comp !== 0 ) {
124134 return comp ;
125135 }
126136 // a and b have the same intermediate form (e.g. "C" => "C", "C++" => "C", "C#" => "C").
127- return a . title . toLowerCase ( ) . localeCompare ( b . title . toLowerCase ( ) ) ;
137+ return /** @type {string } */ ( a . title )
138+ . toLowerCase ( )
139+ . localeCompare ( /** @type {string } */ ( b . title ) . toLowerCase ( ) ) ;
128140 } ) ;
129141
130142 assert . sameOrderedMembers ( languages , sorted ) ;
0 commit comments