Skip to content

@bem-react/di: Check type when setting values in registry #386

@yarastqt

Description

@yarastqt

Неплохо было бы добавить проверку типов при установлении значений в реестре:

interface RegistryComponents {
  ComponentName: ComponentType<ComponentProps>
}

const registry = new Registry<RegistryComponents>({ id: 'registry-id' })

// Component должен быть типом ComponentType<ComponentProps>
registry.set('component-key', Component)

Но могут возникнуть проблемы при переопределении уже существующего реестра:

// Скорее всего ругнется, т.к. компонент EnhancedComponent будет иметь другой тип
registry.set('component-key', EnhancedComponent)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions