programing

npm 패키지의 덮어쓰기 유형 정의

prostudy 2022. 4. 3. 19:51
반응형

npm 패키지의 덮어쓰기 유형 정의

나는 vuexfire와 함께 direct-vuex 패키지를 사용한다.이제 나는 vuexfire와의 호환성을 위해 직접 vuex 패키지에서 몇 가지 타입 디프를 변경해야 해.

내가 어떻게 그럴 수 있을까?

내 타입 파일에 직접 vuex 모듈을 선언해도 아무런 효과가 없다.나의 다른 타입은 작동이 잘 안 된다.

declare module 'direct-vuex' {

  export type ToDirectStore<O extends AppStore> = ShowContent<{
    readonly state: ShowContent<DirectState<O>>
    getters: ShowContent<DirectGetters<O>>
    commit: ShowContent<DirectMutations<O>>
    dispatch: ShowContent<DirectActions<O>>
    original: VuexStore<O>
  }>

  type DirectActions<O extends StoreOrModuleOptions> =
    ToDirectActions<OrEmpty<O['actions']>>
    & GetActionsInModules<FilterNamespaced<OrEmpty<O['modules']>>>
    & MergeActionsFromModules<FilterNotNamespaced<OrEmpty<O['modules']>>>

  type ToDirectActions<T extends ActionsImpl> = {
    [K in keyof T]: Parameters<T[K]>[1] extends undefined
      ? (() => PromiseOf<ReturnType<T[K]>>)
      : ((payload >>>>>> Here i need to add a "?" sign <<<<<<<<<: Parameters<T[K]>[1]) => PromiseOf<ReturnType<T[K]>>)
  }
}

도와줘서 고마워

참조URL: https://stackoverflow.com/questions/60016124/overwrite-type-definition-of-npm-package

반응형