@@ -48,7 +48,8 @@ const parseW3CTextTargets = (annotation: W3CTextAnnotation) => {
4848 updated : modified ? new Date ( modified ) : undefined ,
4949 annotation : annotationId ,
5050 selector : [ ] ,
51- styleClass : w3cTargets [ 0 ] . styleClass
51+ // @ts -expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
52+ styleClass : 'styleClass' in w3cTargets [ 0 ] ? w3cTargets [ 0 ] . styleClass : undefined
5253 } ;
5354
5455 for ( const w3cTarget of w3cTargets ) {
@@ -68,12 +69,14 @@ const parseW3CTextTargets = (annotation: W3CTextAnnotation) => {
6869 } , { } ) ;
6970
7071 if ( isTextSelector ( selector ) ) {
71- parsed . selector . push ( {
72- ...selector ,
73- id : w3cTarget . id ,
74- // @ts -ignore
75- scope : w3cTarget . scope
76- } ) ;
72+ parsed . selector . push (
73+ {
74+ ...selector ,
75+ id : w3cTarget . id ,
76+ // @ts -expect-error: `scope` is not part of the core `TextSelector` type
77+ scope : w3cTarget . scope
78+ }
79+ ) ;
7780 } else {
7881 const missingTypes = [
7982 ! selector . start ? 'TextPositionSelector' : undefined ,
@@ -131,7 +134,7 @@ export const serializeW3CTextAnnotation = (
131134 ...targetRest
132135 } = target ;
133136
134- const w3cTargets = selector . map ( ( s ) => {
137+ const w3cTargets = selector . map ( ( s ) : W3CTextAnnotationTarget => {
135138 const { id, quote, start, end, range } = s ;
136139
137140 const { prefix, suffix } = getQuoteContext ( range , container ) ;
@@ -150,10 +153,11 @@ export const serializeW3CTextAnnotation = (
150153 return {
151154 ...targetRest ,
152155 id,
156+ // @ts -expect-error: `scope` is not part of the core `TextAnnotationTarget` type
153157 scope : 'scope' in s ? s . scope : undefined ,
154158 source,
155159 selector : w3cSelectors
156- } as W3CTextAnnotationTarget ;
160+ } ;
157161 } ) ;
158162
159163
0 commit comments