mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
24 lines
584 B
TypeScript
24 lines
584 B
TypeScript
import { Type } from "./Type"
|
|
|
|
export class BooleanType implements Type {
|
|
public kind = "boolean"
|
|
|
|
constructor(public isDotDotDot = false, public isQuestion = false) {}
|
|
|
|
public toConstructor() {
|
|
return `new BooleanType(${this.isDotDotDot}, ${this.isQuestion})`
|
|
}
|
|
|
|
public toString() {
|
|
return this.kind
|
|
}
|
|
|
|
public convert(argument) {
|
|
if (argument === "true") {
|
|
return true
|
|
} else if (argument === "false") {
|
|
return false
|
|
}
|
|
throw new Error("Can't convert ${argument} to boolean")
|
|
}
|
|
}
|