Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

Latest commit

 

History

History
22 lines (15 loc) · 377 Bytes

tString.md

File metadata and controls

22 lines (15 loc) · 377 Bytes

tString

import { typedec, tString } from "typedec";

@typedec()
class TestClass {
    @tString() public foo: string;

    constructor(@tString() foo: string) {
        this.foo = foo;
    }
}

new TestClass(null); // TypeError: 0 must be a string

const t: TestClass = new TestClass("foo");

t.foo = 100; // TypeError: foo must be a string

t.foo = "baz";