@@ -26,9 +26,11 @@ export async function createTranslationLoader(): Promise<TranslationLoader> {
26
26
const content = fs . readFileSync ( path , 'utf8' ) ;
27
27
const unusedParsers = new Map ( ) ;
28
28
for ( const [ format , parser ] of Object . entries ( parsers ) ) {
29
- const analysis = analyze ( parser , path , content ) ;
29
+ const analysis = parser . analyze ( path , content ) ;
30
30
if ( analysis . canParse ) {
31
- const { locale, translations } = parser . parse ( path , content , analysis . hint ) ;
31
+ // Types don't overlap here so we need to use any.
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ const { locale, translations } = parser . parse ( path , content , analysis . hint as any ) ;
32
34
const integrity = 'sha256-' + createHash ( 'sha256' ) . update ( content ) . digest ( 'base64' ) ;
33
35
34
36
return { format, locale, translations, diagnostics, integrity } ;
@@ -46,18 +48,6 @@ export async function createTranslationLoader(): Promise<TranslationLoader> {
46
48
messages . join ( '\n' ) ,
47
49
) ;
48
50
} ;
49
-
50
- // TODO: `parser.canParse()` is deprecated; remove this polyfill once we are sure all parsers provide the `parser.analyze()` method.
51
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
- function analyze ( parser : any , path : string , content : string ) {
53
- if ( parser . analyze !== undefined ) {
54
- return parser . analyze ( path , content ) ;
55
- } else {
56
- const hint = parser . canParse ( path , content ) ;
57
-
58
- return { canParse : hint !== false , hint, diagnostics } ;
59
- }
60
- }
61
51
}
62
52
63
53
async function importParsers ( ) {
0 commit comments