mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 10:01:39 -05:00
Merge pull request #1187 from glacambre/singleton_types
Metadata Types: Use a single type instance where it makes sense
This commit is contained in:
commit
2a520a3b2a
5 changed files with 10 additions and 5 deletions
|
@ -1,12 +1,13 @@
|
||||||
import { Type } from "./Type"
|
import { Type } from "./Type"
|
||||||
|
|
||||||
export class AnyType implements Type {
|
export class AnyType implements Type {
|
||||||
|
static instance = new AnyType()
|
||||||
kind = "any"
|
kind = "any"
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
toConstructor() {
|
toConstructor() {
|
||||||
return "new AnyType()"
|
return "AnyType.instance"
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { Type } from "./Type"
|
import { Type } from "./Type"
|
||||||
|
|
||||||
export class BooleanType implements Type {
|
export class BooleanType implements Type {
|
||||||
|
static instance = new BooleanType()
|
||||||
kind = "boolean"
|
kind = "boolean"
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
toConstructor() {
|
toConstructor() {
|
||||||
return "new BooleanType()"
|
return "BooleanType.instance"
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { Type } from "./Type"
|
import { Type } from "./Type"
|
||||||
|
|
||||||
export class NumberType implements Type {
|
export class NumberType implements Type {
|
||||||
|
static instance = new NumberType()
|
||||||
kind = "number"
|
kind = "number"
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
toConstructor() {
|
toConstructor() {
|
||||||
return "new NumberType()"
|
return "NumberType.instance"
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { Type } from "./Type"
|
import { Type } from "./Type"
|
||||||
|
|
||||||
export class StringType implements Type {
|
export class StringType implements Type {
|
||||||
|
static instance = new StringType()
|
||||||
kind = "string"
|
kind = "string"
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
toConstructor() {
|
toConstructor() {
|
||||||
return "new StringType()"
|
return "StringType.instance"
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { Type } from "./Type"
|
import { Type } from "./Type"
|
||||||
|
|
||||||
export class VoidType implements Type {
|
export class VoidType implements Type {
|
||||||
|
static instance = new VoidType()
|
||||||
kind = "void"
|
kind = "void"
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
toConstructor() {
|
toConstructor() {
|
||||||
return "new VoidType()"
|
return "VoidType.instance"
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue