Typescript TS2339 Property doesn't exist on type - Class decleration

前端 未结 2 1524
孤独总比滥情好
孤独总比滥情好 2021-01-26 23:07

I am using exact example outlined in Typescript https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html#classes

This is exact copy I am running in app

2条回答
  •  粉色の甜心
    2021-01-26 23:38

    This seems to work fine?

    var Student = (function() {
      function Student(firstName, middleInitial, lastName) {
        this.firstName = firstName;
        this.middleInitial = middleInitial;
        this.lastName = lastName;
        this.fullName = firstName + " " + middleInitial + " " + lastName;
      }
      return Student;
    }());
    
    function greeter(person) {
      return "Hello, " + person.firstName + " " + person.lastName;
    }
    var user = new Student("Jane", "M.", "User");
    document.body.innerHTML = greeter(user);

提交回复
热议问题