@@ -27,7 +27,7 @@ export class TypeGuard {
2727
2828 public static checkNumber ( value : unknown ) : number {
2929 if ( ! TypeGuard . isNumber ( value ) ) {
30- throw new Error ( 'Type is not a number' ) ;
30+ throw new TypeError ( 'Type is not a number' ) ;
3131 }
3232
3333 return value ;
@@ -41,7 +41,7 @@ export class TypeGuard {
4141
4242 public static checkString ( value : unknown ) : string {
4343 if ( ! TypeGuard . isString ( value ) ) {
44- throw new Error ( 'Type is not a string' ) ;
44+ throw new TypeError ( 'Type is not a string' ) ;
4545 }
4646
4747 return value ;
@@ -69,7 +69,7 @@ export class TypeGuard {
6969
7070 public static checkArray ( value : unknown ) : [ ] {
7171 if ( ! TypeGuard . isArray ( value ) ) {
72- throw new Error ( 'Type is not an array.' ) ;
72+ throw new TypeError ( 'Type is not an array.' ) ;
7373 }
7474
7575 return value ;
@@ -83,7 +83,7 @@ export class TypeGuard {
8383
8484 public static checkArrayOfStrings ( value : unknown ) : string [ ] {
8585 if ( ! TypeGuard . isArrayOfStrings ( value ) ) {
86- throw new Error ( 'Type is not an array of strings.' ) ;
86+ throw new TypeError ( 'Type is not an array of strings.' ) ;
8787 }
8888
8989 return value ;
@@ -97,7 +97,7 @@ export class TypeGuard {
9797
9898 public static checkArrayWithElements < T > ( value : unknown ) : [ T , ...T [ ] ] {
9999 if ( ! TypeGuard . isArrayWithElements < T > ( value ) ) {
100- throw new Error ( 'Type is not an array with elements.' ) ;
100+ throw new TypeError ( 'Type is not an array with elements.' ) ;
101101 }
102102
103103 return value ;
@@ -111,7 +111,7 @@ export class TypeGuard {
111111
112112 public static checkDefinedObject ( value : unknown ) : object {
113113 if ( ! TypeGuard . isDefinedObject ( value ) ) {
114- throw new Error ( 'Type is not an object.' ) ;
114+ throw new TypeError ( 'Type is not an object.' ) ;
115115 }
116116
117117 return value ;
@@ -201,7 +201,7 @@ export class TypeGuard {
201201 }
202202
203203 if ( missingKeys . length > 0 ) {
204- throw toThrow ?? new Error ( `Object lacks these properties: ${ String ( keys ) } .` ) ;
204+ throw toThrow ?? new TypeError ( `Object lacks these properties: ${ String ( keys ) } .` ) ;
205205 }
206206
207207 return obj as EnsureKeysAreSet < T , K > ;
0 commit comments