标识符“ n”未定义,“对象”不包含此类成员

Ste*_*oot 5 templates visual-studio-code angular

Angular当我处理不在基类上的继承类型的成员并且在组件上声明了基类时,Visual Studio Code(1.17.0)在模板中生成错误。
在下面的代码中,显然maxLength不存在QuestionBase,但是我该如何处理?

[角度]标识符'maxLength'未定义。“ QuestionBase”不包含此类成员

export class QuestionBase {
  id: number;
  order: number;
}

export class TextQuestion extends QuestionBase {
  maxLength: number
}
Run Code Online (Sandbox Code Playgroud)

在组件上,问题被声明为QuestionBase,因此它可以成为任何一种问题

@Import question: QuestionBase
Run Code Online (Sandbox Code Playgroud)

现在在html模板中,我添加了maxLength属性:

<input type="text" class="form-control" id="maxLength" [(ngModel)]="question.maxLength" name="maxLength" />
Run Code Online (Sandbox Code Playgroud)

Cha*_*dru 5

像这样尝试:

问题库.ts

export class QuestionBase {
  id: number;
  order: number;
}

export class TextQuestion extends QuestionBase {
  maxLength: number
}
Run Code Online (Sandbox Code Playgroud)

组件.ts

import { QuestionBase } from './';

export class Component {

    private question: QuestionBase = new QuestionBase();

    constructor() { }
}
Run Code Online (Sandbox Code Playgroud)

组件.html

<input type="text" class="form-control" id="maxLength" [(ngModel)]="question.maxLength" name="maxLength" />
Run Code Online (Sandbox Code Playgroud)