[core] fixed typescript issues
This commit is contained in:
@@ -30,8 +30,8 @@ import { FeatureFlagName } from '../../plugin/types';
|
||||
*/
|
||||
|
||||
export enum FeatureFlagState {
|
||||
NotEnabled = false,
|
||||
Enabled = true,
|
||||
NotEnabled = 0,
|
||||
Enabled = 1,
|
||||
}
|
||||
|
||||
export type FeatureFlagsApi = {
|
||||
|
||||
@@ -91,7 +91,7 @@ export default class AppBuilder {
|
||||
}
|
||||
case 'feature-flag': {
|
||||
registeredFeatureFlags.push({
|
||||
pluginId: plugin.config.id,
|
||||
pluginId: plugin.getId(),
|
||||
name: output.name,
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { ComponentType, createContext, FC } from 'react';
|
||||
import React, { ReactNode, createContext, FC } from 'react';
|
||||
import { FeatureFlagName } from '../plugin/types';
|
||||
import {
|
||||
FeatureFlagState,
|
||||
@@ -37,14 +37,20 @@ class FeatureFlagsImpl implements FeatureFlagsApi {
|
||||
const featureFlagsJson = window.localStorage.getItem(
|
||||
this.localStorageKey,
|
||||
);
|
||||
return new Set<>(Object.keys(JSON.parse(featureFlagsJson!)));
|
||||
return new Set<FeatureFlagName>(
|
||||
Object.keys(JSON.parse(featureFlagsJson!)),
|
||||
);
|
||||
} catch (err) {
|
||||
return new Set<>();
|
||||
return new Set<FeatureFlagName>();
|
||||
}
|
||||
}
|
||||
|
||||
get(name: FeatureFlagName): FeatureFlagState {
|
||||
return this.getUserEnabledFeatureFlags().has(name) as FeatureFlagState;
|
||||
if (this.getUserEnabledFeatureFlags().has(name)) {
|
||||
return FeatureFlagState.Enabled;
|
||||
}
|
||||
|
||||
return FeatureFlagState.NotEnabled;
|
||||
}
|
||||
|
||||
set(name: FeatureFlagName, state: FeatureFlagState): void {
|
||||
@@ -83,7 +89,7 @@ export const FeatureFlagsContext = createContext<{
|
||||
|
||||
interface Props {
|
||||
registeredFeatureFlags: FeatureFlagsEntry[];
|
||||
children: ComponentType;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export const FeatureFlagsContextProvider: FC<Props> = ({
|
||||
|
||||
@@ -64,6 +64,10 @@ export default class Plugin {
|
||||
|
||||
constructor(private readonly config: PluginConfig) {}
|
||||
|
||||
getId(): string {
|
||||
return this.config.id;
|
||||
}
|
||||
|
||||
output(): PluginOutput[] {
|
||||
if (this.storedOutput) {
|
||||
return this.storedOutput;
|
||||
|
||||
@@ -28,7 +28,6 @@ import { render } from '@testing-library/react';
|
||||
export { default as Keyboard } from './Keyboard';
|
||||
export { default as mockBreakpoint } from './mockBreakpoint';
|
||||
export * from './logCollector';
|
||||
export * from './decorators';
|
||||
|
||||
export function wrapInTestApp(Component, initialRouterEntries) {
|
||||
const Wrapper = Component instanceof Function ? Component : () => Component;
|
||||
|
||||
Reference in New Issue
Block a user