File tree Expand file tree Collapse file tree 2 files changed +17
-17
lines changed
TypeScriptBasic/0x_Decorators Expand file tree Collapse file tree 2 files changed +17
-17
lines changed Original file line number Diff line number Diff line change 1
- import { StringUtility } from " ./Decorators" ;
1
+ import { StringUtility } from ' ./Decorators' ;
2
2
3
- test ( " [TypeScriptBasic/0x_Decorators] Pengecekan Class Decorator" , ( ) => {
4
- expect ( new StringUtility ( [ " Test" ] ) . data [ 0 ] ) . toBe ( " Teks pengganti argumen pertama" ) ;
5
- } )
3
+ test ( ' [TypeScriptBasic/0x_Decorators] Pengecekan Class Decorator' , ( ) => {
4
+ expect ( new StringUtility ( [ ' Test' ] ) . data [ 0 ] ) . toBe ( ' Teks pengganti argumen pertama' ) ;
5
+ } ) ;
6
6
7
- test ( "[TypeScriptBasic/0x_Decorators] Pengecekan Property Decorator" , ( ) => {
8
- // @ts -expect-error
9
- expect ( new StringUtility ( "abc" ) ) . toThrowError ( ) ;
10
- } )
7
+ test ( '[TypeScriptBasic/0x_Decorators] Pengecekan Property Decorator' , ( ) => {
8
+ expect ( new StringUtility ( [ 'abc' ] ) ) . toThrowError ( ) ;
9
+ } ) ;
11
10
12
- test ( " [TypeScriptBasic/0x_Decorators] Pengecekan Method Decorator" , ( ) => {
13
- expect ( StringUtility . prototype . sambungData = ( ) => { return "" } ) . toThrowError ( ) ;
14
- } )
11
+ test ( ' [TypeScriptBasic/0x_Decorators] Pengecekan Method Decorator' , ( ) => {
12
+ expect ( StringUtility . prototype . sambungData = ( ) => { return '' ; } ) . toThrowError ( ) ;
13
+ } ) ;
Original file line number Diff line number Diff line change 1
1
// Penjelasan akan ditulis nanti.
2
2
3
- function gantiArgumenConstructor ( constructor : typeof StringUtility ) : any {
3
+ function gantiArgumenConstructor ( constructor : typeof StringUtility ) : typeof StringUtility {
4
4
return class extends constructor {
5
5
constructor ( args : string [ ] ) {
6
- super ( [ " Teks pengganti argumen pertama" , ...args ] ) ;
6
+ super ( [ ' Teks pengganti argumen pertama' , ...args ] ) ;
7
7
}
8
- }
8
+ } ;
9
9
}
10
10
11
- function buatMethodTidakDapatDiubah ( target : any , key : string , descriptor : PropertyDescriptor ) {
11
+ function buatMethodTidakDapatDiubah ( target : StringUtility , key : string , descriptor : PropertyDescriptor ) {
12
12
descriptor . writable = false ;
13
13
}
14
14
15
- function harusBerupaArray ( target : any , key : string ) {
15
+ function harusBerupaArray ( target : StringUtility , key : string ) {
16
+ // @ts -expect-error ignore error
16
17
if ( ! Array . isArray ( target [ key ] ) ) {
17
18
throw new Error ( `${ key } harus berupa array` ) ;
18
19
}
@@ -41,4 +42,4 @@ class StringUtility {
41
42
42
43
export {
43
44
StringUtility
44
- }
45
+ } ;
You can’t perform that action at this time.
0 commit comments