typescript-book icon indicating copy to clipboard operation
typescript-book copied to clipboard

Create a section on `definite-assignment` similar to strict null checks

Open basarat opened this issue 7 years ago • 3 comments

Document the definite assignment operator for class properties and variables in general :

class C {
    foo!: number;
    // ^
    // Notice this exclamation point!
    // This is the "definite assignment assertion" modifier.
    constructor() {
        this.initialize();
    }

    initialize() {
        this.foo = 0;
    }
}

and

let x!: number[];
initialize();
x.push(4);

function initialize() {
    x = [0, 1, 2, 3];
}

Ref: https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#stricter-class-property-checks

basarat avatar Feb 01 '18 01:02 basarat

@basarat Hello, I would like to translate to Spanish but I do not know how. I would like to do it by means of pull request :)

jossue33 avatar Feb 18 '18 07:02 jossue33

@jossue33 You could fork this project, then join GitBook (which @basarat uses to publish this book) and add your fork from the “GitHub” option. Then you can host your translated site under your own account. @basarat would probably be able to link to it from the main book’s homepage.

j-f1 avatar Feb 18 '18 12:02 j-f1

@j-f1 ok thanks

jossue33 avatar Mar 05 '18 21:03 jossue33