0
interface Props {
  youtube: {
    oauth2PrefixUrl: string
    apiPrefixUrl: string
    clientId: string
    clientSecret: string
    accessToken: string
    refreshToken: string
    channelId: string
    channelWatchUrl: string
  }
  peertube: {
    apiPrefixUrl: string
    clientId: string
    clientSecret: string
    accessToken: string
    refreshToken: string
    accountName: string
    channelId: string
    channelWatchUrl: string
  }
}

// I wish to accept the following
const test1: SpecialType = {
  youtube: {
    oauth2PrefixUrl: "https://accounts.google.com/o/oauth2"
  }
}

// But not this
const test2: SpecialType = {
  youtube: {
    foo: "This property should not be allowed"
  }
}
sunknudsen
  • 6,356
  • 3
  • 39
  • 76

1 Answers1

0

Figured it out thanks to https://stackoverflow.com/a/61132308/4579271.

type DeepPartial<T> = {
  [P in keyof T]?: DeepPartial<T[P]>
}

type SpecialType = DeepPartial<Props>
sunknudsen
  • 6,356
  • 3
  • 39
  • 76