Created
          August 24, 2024 15:09 
        
      - 
      
- 
        Save bruno-sartori/b2fe6e544870a35089240ac06f363dd8 to your computer and use it in GitHub Desktop. 
    Clone interface with optional parameters but make them required
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | interface IOptionalPropertiesSubInterface { | |
| width?: number; | |
| height?: number; | |
| opacity?: number; | |
| lineHeight?: number; | |
| } | |
| interface IOptionalPropertiesInterface { | |
| enabled?: boolean, | |
| visual?: boolean, | |
| propertyThatImplementsSubInterface?: IOptionalPropertiesSubInterface, | |
| } | |
| // Tipo auxiliar para tornar todas as propriedades obrigatórias e profundas | |
| type DeepRequired<T> = { | |
| [P in keyof T]-?: T[P] extends object | |
| ? T[P] extends (...args: any[]) => any | |
| ? T[P] | |
| : DeepRequired<Required<T[P]>> | |
| : T[P]; | |
| }; | |
| declare type IRequiredPropertiesSubInterface = DeepRequired<IOptionalPropertiesSubInterface>; | |
| // Ajustando a configuração do logger para usar IRequiredContainerStyle para containerStyle | |
| export declare type IRequiredPropertiesInterface = Omit<DeepRequired<IOptionalPropertiesInterface>, 'propertyThatImplementsSubInterface'> & { | |
| propertyThatImplementsSubInterface: IRequiredPropertiesSubInterface; | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment