[typeScript] js类型推导错误

Version: 3.2.2
我有一个 person.js 文件和 test.ts 文件,在 js 文件中创建了一个 student 类和 person 对象,并且把 student 的 prototype 设置为 person,然后导出 student 的实例。
接着,在 test 文件中访问 student 的实例,但是 ts 却访问不到 student 的 prototype 上的属性(也就是 person 上的属性)。

person.js

let student = function () {    this.age=12;
}let person = {};
person.name=22;
student.prototype=person;let tom = new student();

exports.tom =tom;

test.ts

import * as person from './person';
person.tom.name

https://img4.mukewang.com/5c6c02d900013aee06300118.jpg

万千封印
浏览 853回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

React.JS