Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to set a read only property doesn't cause a compiler error #6429

Closed
mareek opened this issue Jan 10, 2016 · 2 comments
Closed

trying to set a read only property doesn't cause a compiler error #6429

mareek opened this issue Jan 10, 2016 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@mareek
Copy link

mareek commented Jan 10, 2016

If one try to set a property that hasn't any getter defined, the compiler doesn't emit any error or warning and the code silently fails à runtime.

example:

class Greeter {
    private _greeting: string;
    get greeting(): string { return this._greeting; }

    constructor(message: string) {
        this.greeting = message; //no error at compile time and silent failure at execution time
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}
@kitsonk
Copy link
Contributor

kitsonk commented Jan 10, 2016

Essentially a dupe of #295 (and other issues) but related to/would be fixable by #12 being resolved.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 11, 2016
@RyanCavanaugh
Copy link
Member

Please search for duplicates before logging issues.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants