mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-15 09:46:30 -04:00
22 lines
461 B
TypeScript
22 lines
461 B
TypeScript
import { Type } from "./Type"
|
|
|
|
export class StringType implements Type {
|
|
public static instance = new StringType()
|
|
public kind = "string"
|
|
|
|
public toConstructor() {
|
|
return "StringType.instance"
|
|
}
|
|
|
|
public toString() {
|
|
return this.kind
|
|
}
|
|
|
|
public convert(argument) {
|
|
if (typeof argument === "string") {
|
|
return argument
|
|
}
|
|
throw new Error(`Can't convert to string: ${argument}`)
|
|
}
|
|
}
|