1. tsconfig.json에 아래와 같은 설정
    {
    "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
     "paths": {
       "@/*": [
         "./*"
       ],
       "@test/*": [
         "test/*"
       ]
     }
    }
  2. tsconfig-paths 필요
    npm i tsconfig-paths
type Foo = {
    isSubscribed: boolean
    [field: string]: string
}


이렇게 쓰면 isSubscribed 가 index signaure 형식에 맞지 않아서 적용할 수가 없다.


type Foo = {
    isSubscribed: boolean
} & {
    [field: string]: string
}


intersection으로는 선언이 가능하다. 


const bar: Foo = {
    isSubscribed: true,
    name: "wook"
}


하지만 이런식으로 변수 설정을 할 수 없다.


const bar: Foo = Object.assign(
    {
        isSubscribed: true,
    },
    {
        name: "wook"
    }
);


이런식으로 할당하던지


declare const bar: Foo;

bar.isSubscribed = true;
bar.name = "wook";


이런식으로 선언해야 한다.

"Types_have_separate_declarations_of_a_private_property_0_2442": "형식에 별도의 전용 속성 '{0}' 선언이 있습니다.",


private 속성이 있으면 상속이 안된다


+ Recent posts