Angular – Property does not exist on type

I am new to Angular. I took the following example from a book, to get familiar with javascript classes. I try to load it using main.ts . However, I get the following error: error TS2551: Property ‘_weather’ does not exist on type ‘MyClass’. Did you mean ‘weather’? Can anybody explain me why? It should work, it is a copy/paste from a book. I can make it work if I manually add _weather: string; and name: string; declarations. But it shouldn’t be necessary.

 class MyClass {
        constructor(name, weather) {
   = name;
            this._weather = weather;
        set weather(value) {
            this._weather = value;
        get weather() {
            return `Today is ${this._weather}`;
        printMessages() {
            console.log("Hello " + + ". ");
    let myData = new MyClass("Adam", "sunny");

63 thoughts on “Angular – Property does not exist on type”

  1. 148388 367921Need to tow line this caravan together with van trailer home your entire family fast get exposed towards the issues along with reversing create tight placement. awnings 323720

  2. 995014 847265jobs for high school students – Search for Jobs on our web site, we supply several excellent links towards the best and biggest Portals to obtaining a Job as a high school student! 113624


Leave a Comment