@@ -362,10 +362,14 @@ export default class ArticleEditor extends React.Component<Props, State> {
362
362
363
363
serialize ( ) : JsonType {
364
364
if ( this . props . mode === "edit" ) {
365
+ // Note(jeremy): Fixing this type error involves some extensive
366
+ // re-working of the may <Editor /> component. Today it accepts a
367
+ // `replace` prop (I _think_ because it's also used for editing
368
+ // hints), but when I tried to re-work it I couldn't decipher which
369
+ // types to fix and which to not fix.
370
+ // @ts -expect-error - TS2322 - Type 'undefined' is not assignable to type 'PerseusRenderer'.ts
365
371
return this . _sections ( ) . map ( ( section , i ) => {
366
- // eslint-disable-next-line react/no-string-refs
367
- // @ts -expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
368
- return this . refs [ "editor" + i ] . serialize ( ) ;
372
+ return this . editorRefs [ i ] ?. serialize ( ) ;
369
373
} ) ;
370
374
}
371
375
if ( this . props . mode === "preview" || this . props . mode === "json" ) {
@@ -378,12 +382,12 @@ export default class ArticleEditor extends React.Component<Props, State> {
378
382
}
379
383
380
384
/**
381
- * Returns an array, with one element be section.
385
+ * Returns an array, with one element per section.
382
386
* Each element is an array of lint warnings present in that section.
383
387
*
384
388
* This function can currently only be called in edit mode.
385
389
*/
386
- getSaveWarnings ( ) : ReadonlyArray < Renderer > {
390
+ getSaveWarnings ( ) : ReadonlyArray < ReadonlyArray < string > > {
387
391
if ( this . props . mode !== "edit" ) {
388
392
// TODO(joshuan): We should be able to get save warnings in
389
393
// preview mode.
@@ -394,9 +398,7 @@ export default class ArticleEditor extends React.Component<Props, State> {
394
398
}
395
399
396
400
return this . _sections ( ) . map ( ( section , i ) => {
397
- // eslint-disable-next-line react/no-string-refs
398
- // @ts -expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
399
- return this . refs [ "editor" + i ] . getSaveWarnings ( ) ;
401
+ return this . editorRefs [ i ] ?. getSaveWarnings ( ) ?? [ ] ;
400
402
} ) ;
401
403
}
402
404
0 commit comments