refactor: remove as any of file jsonUtils.test.ts
refactor: extract `DataType` as the return type of function `getDataType`
This commit is contained in:
@@ -25,10 +25,19 @@ export type JsonSchemaType = {
|
||||
|
||||
export type JsonObject = { [key: string]: JsonValue };
|
||||
|
||||
const typeofVariable = typeof "random variable";
|
||||
export function getDataType(
|
||||
value: JsonValue,
|
||||
): typeof typeofVariable | "array" | "null" {
|
||||
export type DataType =
|
||||
| "string"
|
||||
| "number"
|
||||
| "bigint"
|
||||
| "boolean"
|
||||
| "symbol"
|
||||
| "undefined"
|
||||
| "object"
|
||||
| "function"
|
||||
| "array"
|
||||
| "null";
|
||||
|
||||
export function getDataType(value: JsonValue): DataType {
|
||||
if (Array.isArray(value)) return "array";
|
||||
if (value === null) return "null";
|
||||
return typeof value;
|
||||
|
||||
Reference in New Issue
Block a user