typescript(option): feat: custom toString method for better logging
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
b388fb76aa
commit
1178d04079
2 changed files with 503 additions and 0 deletions
typescript/option/src
|
@ -8,10 +8,18 @@ export class SomeClass<T> {
|
|||
public constructor(value: T) {
|
||||
this[someValue] = value
|
||||
}
|
||||
|
||||
public toString() {
|
||||
return `Some(${this[someValue]})`
|
||||
}
|
||||
}
|
||||
|
||||
export class NoneClass {
|
||||
public [isOption] = true
|
||||
|
||||
public toString() {
|
||||
return 'None'
|
||||
}
|
||||
}
|
||||
|
||||
export default { NoneClass, SomeClass, isOption, someValue }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue