답변

0
  1. 을 보여 바인딩 라인에 실패 무엇을 적용

    // file interfaces.ts 
    interface Warrior { 
        fight(): string; 
    } 
    
    // file types.ts 
    const TYPES = { 
        Warrior: Symbol("Warrior") 
    }; 
    export { TYPES }; 
    
    // file entities.ts 
    import { injectable, inject } from "inversify"; 
    import "reflect-metadata"; 
    import { Warrior } from "./interfaces" 
    import { TYPES } from "./types"; 
    
    @injectable() 
    class WarriorImpl implements Warrior { 
        public constructor(){ 
        } 
        public fight() { return "I fight"; } 
    } 
    export { WarriorImpl }; 
    
    // file inversify.config.ts 
    import { Container } from "inversify"; 
    import TYPES from "./types"; 
    import { Warrior } from "./interfaces"; 
    import { WarriorImpl } from "./entities"; 
    const myContainer = new Container(); 
    myContainer.bind<Warrior>(TYPES.Warrior).to(WarriorImpl); 
    export { myContainer }; 
    

    : 나는 https://github.com/inversify/InversifyJS 페이지의 예를 사용하여 시작 그것이 가져올의 인터페이스 :

    // file interfaces.ts 
    export interface Warrior { 
        fight(): string; 
    } 
    
  2. inversify.config.ts에있는 당신의 수입이 있어야한다 :

    import { TYPES } from "./types"; 
    
  3. 실제로 라이브러리 (npm install inversify)를 설치했는지 확인하십시오. 오류 Untyped function calls may not accept type arguments은 누락 된 유형 정보입니다.

+0

내가 제공 한 것을 적용했는데 문제는 인터페이스 이름이 인 다이아몬드 연산자 사용에 관한 것입니다. 이 문제를 해결하는 방법을 모르겠습니다. – alibenmessaoud

+0

TypeScript가 라이브러리의 타이핑을 찾을 수 있습니까? 'const myContainer = new Container();를 입력하면 VS 코드에서 인텔리 센스를 얻고 있습니까? myContainer.'? – Saravana

+0

'tsc' 명령은 같은 오류를 보여줍니다. 그것은 VScode와 관련이 없습니다. – alibenmessaoud

관련 문제