File tree 3 files changed +14
-4
lines changed
common/changes/@educorvi/rita
3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "changes" : [
3
+ {
4
+ "packageName" : " @educorvi/rita" ,
5
+ "comment" : " fix type guard for ArrayLike" ,
6
+ "type" : " patch"
7
+ }
8
+ ],
9
+ "packageName" : " @educorvi/rita"
10
+ }
Original file line number Diff line number Diff line change @@ -54,11 +54,11 @@ export function assertDuration(
54
54
}
55
55
}
56
56
57
- export function hasLength (
57
+ export function assertArrayLike (
58
58
value : unknown ,
59
59
context : Formula
60
60
) : asserts value is unknown & { length : number } {
61
- if ( ! value || ! value . hasOwnProperty ( 'length' ) ) {
61
+ if ( ! value ? .hasOwnProperty ( 'length' ) ) {
62
62
throw new HasNoLengthError ( context , value ) ;
63
63
}
64
64
}
Original file line number Diff line number Diff line change 1
1
import { Formula , FormulaResults } from './Formula' ;
2
2
import { Atom } from './Atom' ;
3
- import { hasLength } from '../Assertions' ;
3
+ import { assertArrayLike } from '../Assertions' ;
4
4
5
5
export class Macro extends Formula {
6
6
/** Indicates the type of this atom **/
@@ -21,7 +21,7 @@ export class Macro extends Formula {
21
21
return new Date ( ) ;
22
22
case 'length' :
23
23
const ar = await this . array ?. evaluate ( data ) ;
24
- hasLength ( ar , this ) ;
24
+ assertArrayLike ( ar , this ) ;
25
25
return ar . length ;
26
26
}
27
27
}
You can’t perform that action at this time.
0 commit comments