Skip to content

I can access a private variable but don't get an typescript error  #17717

@kevincam3

Description

@kevincam3

typescript-no-error-accessing-private-property
TypeScript Version: 2.4.2

Code
import {Component, OnInit} from '@angular/core';

@component({
selector: 'app-servers',
template: './servers.component.html',
styleUrls: ['./servers.component.css']
})
export class ServersComponent implements OnInit {
private allowNewServer: boolean = false;

constructor() {
    setTimeout(() => {
        this.allowNewServer = true;
    }, 2000);
}

ngOnInit() {
}

}

// A *self-contained* demonstration of the problem follows...
See [screenshot](url

)
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

Expected behavior:
Typescript Error message that I'm using a private variable

Actual behavior:
No Warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions