내가이 내가타이프 라이터 모듈하지
import {Component, OnInit} from '@angular/core';
import {BackendUrl} from '../../../../common/settings';
import {contentHeaders} from "../../../../common/headers";
import {EventService} from "../../../../service/event.service";
import {Input} from "@angular/core/src/metadata/directives";
import {Message} from "stompjs";
import {Target} from "target";
@Component({
selector: 'device-switch',
templateUrl: './switch.component.html'
})
export class SwitchComponent implements OnInit {
@Input()
public title: string;
@Input()
public device: any;
@Input()
public property: any;
private checked: boolean;
constructor(public authHttp: AuthHttp, private eventService: EventService) {
this.checked = false;
}
ngOnInit() {
this.eventService.messages.subscribe(this.on_next);
}
/** Consume a message from the eventService */
public on_next = (message: Message) => {
let data : Target = JSON.parse(message.body);
if(data.device.id === this.device.id && data.property.name === this.property.name) {
this.checked = (data.value.value > 0);
}
};
}
문제와 같은 구성 요소에 정의 된 인터페이스를 사용하고 지금 target.d.ts
declare module "target" {
export interface Group {
name: string;
targets?: Target[];
}
export interface Target {
device: Device;
property: Property;
value?: Value;
}
export interface Value {
value: number;
id?: number;
timestamp?: number;
}
export interface Property {
id: number;
name: string;
channel: number;
type: string;
}
export interface Device {
id: number;
name: string;
type: string;
}
}
이 같은 모듈을 정의 발견 그 @Input()
변수 device
및 property
은 내 target
모듈에도 정의 된 인터페이스 유형입니다.
하지만 import {Target, Device, Property} from "target";
경우 컴파일러가 문제가 ... IntelliJ에 아무것도 강조하지 않습니다 무슨
ERROR in ./src/app/component/view/part/device/switch.component.ts
Module not found: Error: Can't resolve 'target' in '~/git/xx/frontend/src/app/component/view/part/device'
@ ./src/app/component/view/part/device/switch.component.ts 16:0-28
@ ./src/app/component/view/part/group.component.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi main
내가 모르는 오류가 발생합니다 ... 괜찮을 것 같다.