mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
22 lines
526 B
TypeScript
22 lines
526 B
TypeScript
import { Type } from "./Type"
|
|
|
|
export class StringType implements Type {
|
|
public kind = "string"
|
|
|
|
constructor(public isDotDotDot = false, public isQuestion = false) {}
|
|
|
|
public toConstructor() {
|
|
return `new StringType(${this.isDotDotDot}, ${this.isQuestion})`
|
|
}
|
|
|
|
public toString() {
|
|
return this.kind
|
|
}
|
|
|
|
public convert(argument) {
|
|
if (typeof argument === "string") {
|
|
return argument
|
|
}
|
|
throw new Error(`Can't convert to string: ${argument}`)
|
|
}
|
|
}
|