@@ -37,9 +37,13 @@ type ChangeReporter = (
3737  current ?: JsonValue , 
3838)  =>  void ; 
3939
40+ // lib.es5 PropertyKey is string | number | symbol which doesn't overlap ProxyHandler PropertyKey which is string | symbol. 
41+ // See https://github.com/microsoft/TypeScript/issues/42894 
42+ type  ProxyPropertyKey  =  string  |  symbol ; 
43+ 
4044function  findNode ( 
4145  parent : JsonAstArray  |  JsonAstObject , 
42-   p : PropertyKey , 
46+   p : ProxyPropertyKey , 
4347) : {  node ?: JsonAstNode ;  parent : JsonAstArray  |  JsonAstKeyValue  |  JsonAstObject  }  { 
4448  if  ( parent . kind  ===  'object' )  { 
4549    const  entry  =  parent . properties . find ( entry  =>  entry . key . value  ===  p ) ; 
@@ -120,8 +124,8 @@ function create(
120124  ast : JsonAstObject  |  JsonAstArray , 
121125  path : string , 
122126  reporter : ChangeReporter , 
123-   excluded  =  new  Set < PropertyKey > ( ) , 
124-   included ?: Set < PropertyKey > , 
127+   excluded  =  new  Set < ProxyPropertyKey > ( ) , 
128+   included ?: Set < ProxyPropertyKey > , 
125129  base ?: object , 
126130)  { 
127131  const  cache  =  new  Map < string ,  CacheEntry > ( ) ; 
@@ -137,7 +141,7 @@ function create(
137141  } 
138142
139143  return  new  Proxy ( base ,  { 
140-     getOwnPropertyDescriptor ( target : { } ,  p : PropertyKey ) : PropertyDescriptor  |  undefined  { 
144+     getOwnPropertyDescriptor ( target : { } ,  p : ProxyPropertyKey ) : PropertyDescriptor  |  undefined  { 
141145      const  descriptor  =  Reflect . getOwnPropertyDescriptor ( target ,  p ) ; 
142146      if  ( descriptor  ||  typeof  p  ===  'symbol' )  { 
143147        return  descriptor ; 
@@ -162,7 +166,7 @@ function create(
162166
163167      return  undefined ; 
164168    } , 
165-     has ( target : { } ,  p : PropertyKey ) : boolean  { 
169+     has ( target : { } ,  p : ProxyPropertyKey ) : boolean  { 
166170      if  ( Reflect . has ( target ,  p ) )  { 
167171        return  true ; 
168172      }  else  if  ( typeof  p  ===  'symbol'  ||  excluded . has ( p ) )  { 
@@ -171,7 +175,7 @@ function create(
171175
172176      return  cache . has ( path  +  '/'  +  escapeKey ( p ) )  ||  findNode ( ast ,  p )  !==  undefined ; 
173177    } , 
174-     get ( target : { } ,  p : PropertyKey ) : unknown  { 
178+     get ( target : { } ,  p : ProxyPropertyKey ) : unknown  { 
175179      if  ( typeof  p  ===  'symbol'  ||  Reflect . has ( target ,  p ) )  { 
176180        return  Reflect . get ( target ,  p ) ; 
177181      }  else  if  ( excluded . has ( p )  ||  ( included  &&  ! included . has ( p ) ) )  { 
@@ -206,7 +210,7 @@ function create(
206210
207211      return  value ; 
208212    } , 
209-     set ( target : { } ,  p : PropertyKey ,  value : unknown ) : boolean  { 
213+     set ( target : { } ,  p : ProxyPropertyKey ,  value : unknown ) : boolean  { 
210214      if  ( value  ===  undefined )  { 
211215        // setting to undefined is equivalent to a delete 
212216        // tslint:disable-next-line: no-non-null-assertion 
@@ -242,7 +246,7 @@ function create(
242246
243247      return  true ; 
244248    } , 
245-     deleteProperty ( target : { } ,  p : PropertyKey ) : boolean  { 
249+     deleteProperty ( target : { } ,  p : ProxyPropertyKey ) : boolean  { 
246250      if  ( typeof  p  ===  'symbol'  ||  Reflect . has ( target ,  p ) )  { 
247251        return  Reflect . deleteProperty ( target ,  p ) ; 
248252      }  else  if  ( excluded . has ( p )  ||  ( included  &&  ! included . has ( p ) ) )  { 
@@ -279,15 +283,15 @@ function create(
279283
280284      return  true ; 
281285    } , 
282-     defineProperty ( target : { } ,  p : PropertyKey ,  attributes : PropertyDescriptor ) : boolean  { 
286+     defineProperty ( target : { } ,  p : ProxyPropertyKey ,  attributes : PropertyDescriptor ) : boolean  { 
283287      if  ( typeof  p  ===  'symbol' )  { 
284288        return  Reflect . defineProperty ( target ,  p ,  attributes ) ; 
285289      } 
286290
287291      return  false ; 
288292    } , 
289-     ownKeys ( target : { } ) : PropertyKey [ ]  { 
290-       let  keys : PropertyKey [ ] ; 
293+     ownKeys ( target : { } ) : ProxyPropertyKey [ ]  { 
294+       let  keys : ProxyPropertyKey [ ] ; 
291295      if  ( ast . kind  ===  'object' )  { 
292296        keys  =  ast . properties 
293297          . map ( entry  =>  entry . key . value ) 
@@ -299,7 +303,7 @@ function create(
299303      for  ( const  key  of  cache . keys ( ) )  { 
300304        const  relativeKey  =  key . substr ( path . length  +  1 ) ; 
301305        if  ( relativeKey . length  >  0  &&  ! relativeKey . includes ( '/' ) )  { 
302-           keys . push ( unescapeKey ( relativeKey ) ) ; 
306+           keys . push ( ` ${ unescapeKey ( relativeKey ) } ` ) ; 
303307        } 
304308      } 
305309
0 commit comments