Make source prop of Layer optional (#2200)

This commit is contained in:
Xiaoji Chen 2023-06-14 09:56:43 -07:00 committed by GitHub
parent e06086bda0
commit 288f8df4d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,8 +8,9 @@ import type {MapInstance, AnyLayer, CustomLayerInterface} from '../types';
// 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;
type OptionalSource<T> = T extends {source: string} ? Omit<T, 'source'> & {source?: string} : T;
export type LayerProps = OptionalId<AnyLayer | CustomLayerInterface> & {
export type LayerProps = OptionalSource<OptionalId<AnyLayer | CustomLayerInterface>> & {
/** If set, the layer will be inserted before the specified layer */
beforeId?: string;
};