我想使用@Input()将对象从父组件传递到子组件,并在子组件中将其强制转换为接口。 界面定义
export interface IDummy {
name: string;
issueNumber: number;
}
在我的parent.component.ts
dummyVariable = {"name":"typescript","issue":"problem with casting objects to an interface using Input"};
在我的parent.component.html
中 <child-component [dummyVariable]="dummyVariable"></child-component>
在我的child.component.ts
@Input() dummyVariable:IDummy;//it should throw an error saying that it is missing an interface property issueNumber, but it runs successfully without throwing an error.
我做错了什么?