File tree Expand file tree Collapse file tree
TypeScriptBasic/0x_Decorators Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { StringUtility } from " ./Decorators" ;
1+ import { StringUtility } from ' ./Decorators' ;
22
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+ } ) ;
66
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+ } ) ;
1110
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 11// Penjelasan akan ditulis nanti.
22
3- function gantiArgumenConstructor ( constructor : typeof StringUtility ) : any {
3+ function gantiArgumenConstructor ( constructor : typeof StringUtility ) : typeof StringUtility {
44 return class extends constructor {
55 constructor ( args : string [ ] ) {
6- super ( [ " Teks pengganti argumen pertama" , ...args ] ) ;
6+ super ( [ ' Teks pengganti argumen pertama' , ...args ] ) ;
77 }
8- }
8+ } ;
99}
1010
11- function buatMethodTidakDapatDiubah ( target : any , key : string , descriptor : PropertyDescriptor ) {
11+ function buatMethodTidakDapatDiubah ( target : StringUtility , key : string , descriptor : PropertyDescriptor ) {
1212 descriptor . writable = false ;
1313}
1414
15- function harusBerupaArray ( target : any , key : string ) {
15+ function harusBerupaArray ( target : StringUtility , key : string ) {
16+ // @ts -expect-error ignore error
1617 if ( ! Array . isArray ( target [ key ] ) ) {
1718 throw new Error ( `${ key } harus berupa array` ) ;
1819 }
@@ -41,4 +42,4 @@ class StringUtility {
4142
4243export {
4344 StringUtility
44- }
45+ } ;
You can’t perform that action at this time.
0 commit comments