Skip to content

Commit

Permalink
[fix] id in LayerProps should be optional (#1910)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Jul 5, 2022
1 parent 851313c commit 60a560f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import {deepEqual} from '../utils/deep-equal';

import type {MapboxMap, AnyLayer} from '../types';

export type LayerProps = AnyLayer & {
id?: string;
// Omiting property from a union type, see
// https://github.com/microsoft/TypeScript/issues/39556#issuecomment-656925230
type OptionalId<T> = T extends {id: string} ? Omit<T, 'id'> & {id?: string} : T;

export type LayerProps = OptionalId<AnyLayer> & {
/** If set, the layer will be inserted before the specified layer */
beforeId?: string;
};
Expand Down

0 comments on commit 60a560f

Please sign in to comment.