mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-20 03:05:39 +00:00
Remove any
This commit is contained in:
parent
cd45f2943d
commit
c857b9aab9
@ -1,10 +1,10 @@
|
||||
import { ChoiceItem, Info, InputType, UiType } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||
import { addPropertyToMap } from "./SelfServeUtils";
|
||||
import { addPropertyToMap, CommonInputTypes } from "./SelfServeUtils";
|
||||
|
||||
type ValueOf<T> = T[keyof T];
|
||||
interface Decorator {
|
||||
name: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any;
|
||||
name: keyof CommonInputTypes;
|
||||
value: ValueOf<CommonInputTypes>;
|
||||
}
|
||||
|
||||
interface InputOptionsBase {
|
||||
@ -59,9 +59,7 @@ const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
||||
addPropertyToMap(target, propertyName, className, "type", propertyType);
|
||||
addPropertyToMap(target, propertyName, className, "dataFieldName", propertyName);
|
||||
|
||||
decorators.map((decorator: Decorator) =>
|
||||
addPropertyToMap(target, propertyName, className, decorator.name, decorator.value)
|
||||
);
|
||||
decorators.map(decorator => addPropertyToMap(target, propertyName, className, decorator.name, decorator.value));
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -79,7 +79,7 @@ export const addPropertyToMap = <T extends keyof CommonInputTypes, K extends Com
|
||||
target: unknown,
|
||||
propertyName: string,
|
||||
className: string,
|
||||
descriptorName: string,
|
||||
descriptorName: keyof CommonInputTypes,
|
||||
descriptorValue: K
|
||||
): void => {
|
||||
const context =
|
||||
@ -92,11 +92,9 @@ export const updateContextWithDecorator = <T extends keyof CommonInputTypes, K e
|
||||
context: Map<string, CommonInputTypes>,
|
||||
propertyName: string,
|
||||
className: string,
|
||||
descriptorName: string,
|
||||
descriptorName: keyof CommonInputTypes,
|
||||
descriptorValue: K
|
||||
): void => {
|
||||
const descriptorKey = descriptorName as keyof CommonInputTypes;
|
||||
|
||||
if (!(context instanceof Map)) {
|
||||
console.log(context);
|
||||
throw new Error(`@SmartUi should be the first decorator for the class '${className}'.`);
|
||||
@ -104,13 +102,13 @@ export const updateContextWithDecorator = <T extends keyof CommonInputTypes, K e
|
||||
|
||||
const propertyObject = context.get(propertyName) ?? { id: propertyName };
|
||||
|
||||
if (getValue(descriptorKey, propertyObject) && descriptorKey !== "type" && descriptorKey !== "dataFieldName") {
|
||||
if (getValue(descriptorName, propertyObject) && descriptorName !== "type" && descriptorName !== "dataFieldName") {
|
||||
throw new Error(
|
||||
`Duplicate value passed for '${descriptorKey}' on property '${propertyName}' of class '${className}'`
|
||||
`Duplicate value passed for '${descriptorName}' on property '${propertyName}' of class '${className}'`
|
||||
);
|
||||
}
|
||||
|
||||
setValue(descriptorKey, descriptorValue, propertyObject);
|
||||
setValue(descriptorName, descriptorValue, propertyObject);
|
||||
context.set(propertyName, propertyObject);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user