tridactyl/compiler/types/StringType.ts

22 lines
461 B
TypeScript
Raw Normal View History

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}`)
}
}