mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-21 11:47:14 +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 { 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 {
|
interface Decorator {
|
||||||
name: string;
|
name: keyof CommonInputTypes;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
value: ValueOf<CommonInputTypes>;
|
||||||
value: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InputOptionsBase {
|
interface InputOptionsBase {
|
||||||
@ -59,9 +59,7 @@ const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
|||||||
addPropertyToMap(target, propertyName, className, "type", propertyType);
|
addPropertyToMap(target, propertyName, className, "type", propertyType);
|
||||||
addPropertyToMap(target, propertyName, className, "dataFieldName", propertyName);
|
addPropertyToMap(target, propertyName, className, "dataFieldName", propertyName);
|
||||||
|
|
||||||
decorators.map((decorator: Decorator) =>
|
decorators.map(decorator => addPropertyToMap(target, propertyName, className, decorator.name, decorator.value));
|
||||||
addPropertyToMap(target, propertyName, className, decorator.name, decorator.value)
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ export const addPropertyToMap = <T extends keyof CommonInputTypes, K extends Com
|
|||||||
target: unknown,
|
target: unknown,
|
||||||
propertyName: string,
|
propertyName: string,
|
||||||
className: string,
|
className: string,
|
||||||
descriptorName: string,
|
descriptorName: keyof CommonInputTypes,
|
||||||
descriptorValue: K
|
descriptorValue: K
|
||||||
): void => {
|
): void => {
|
||||||
const context =
|
const context =
|
||||||
@ -92,11 +92,9 @@ export const updateContextWithDecorator = <T extends keyof CommonInputTypes, K e
|
|||||||
context: Map<string, CommonInputTypes>,
|
context: Map<string, CommonInputTypes>,
|
||||||
propertyName: string,
|
propertyName: string,
|
||||||
className: string,
|
className: string,
|
||||||
descriptorName: string,
|
descriptorName: keyof CommonInputTypes,
|
||||||
descriptorValue: K
|
descriptorValue: K
|
||||||
): void => {
|
): void => {
|
||||||
const descriptorKey = descriptorName as keyof CommonInputTypes;
|
|
||||||
|
|
||||||
if (!(context instanceof Map)) {
|
if (!(context instanceof Map)) {
|
||||||
console.log(context);
|
console.log(context);
|
||||||
throw new Error(`@SmartUi should be the first decorator for the class '${className}'.`);
|
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 };
|
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(
|
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);
|
context.set(propertyName, propertyObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user