Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to expand imported types? #2295

Closed
FreePhoenix888 opened this issue May 31, 2023 · 2 comments
Closed

How to expand imported types? #2295

FreePhoenix888 opened this issue May 31, 2023 · 2 comments
Labels
question Question about functionality

Comments

@FreePhoenix888
Copy link

Search terms

expand, imported, types

Question

Code: https://github.com/deep-foundation/capacitor-device/blob/6d6eae584c3567c5e381fc8a68f733e157d1ab85/src/device-info.ts#L1

import { BatteryInfo, GetLanguageCodeResult, LanguageTag, DeviceInfo as DeviceGeneralInfo } from "@capacitor/device";
export type DeviceInfo =
  | DeviceGeneralInfo
  | BatteryInfo
  | { languageCode: GetLanguageCodeResult['value'] }
  | { languageTag: LanguageTag['value'] };

I get such documentation:

DeviceInfo: DeviceGeneralInfo | BatteryInfo | {
    languageCode: GetLanguageCodeResult["value"];
} | {
    languageTag: LanguageTag["value"];
}

I would like typedoc to expand those types.
Example:

DeviceInfo: {
  model: string;
  isCharging: boolean;
  ...
}

Is this possible??

Additional information

typescript-json-schema is able to find all the actual properties of DeviceInfo and their descriptions

freephoenix888@freephoenix888:~/Programming/deep/capacitor-device$ typescript-json-schema ./src/device-info.ts DeviceInfo
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "anyOf": [
        {
            "$ref": "#/definitions/DeviceInfo_1"
        },
        {
            "$ref": "#/definitions/BatteryInfo"
        },
        {
            "properties": {
                "languageCode": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        {
            "properties": {
                "languageTag": {
                    "type": "string"
                }
            },
            "type": "object"
        }
    ],
    "definitions": {
        "BatteryInfo": {
            "properties": {
                "batteryLevel": {
                    "description": "A percentage (0 to 1) indicating how much the battery is charged.",
                    "type": "number"
                },
                "isCharging": {
                    "description": "Whether the device is charging.",
                    "type": "boolean"
                }
            },
            "type": "object"
        },
        "DeviceInfo_1": {
            "properties": {
                "diskFree": {
                    "description": "How much free disk space is available on the normal data storage\npath for the os, in bytes.\n\nOn Android it returns the free disk space on the \"system\"\npartition holding the core Android OS.\nOn iOS this value is not accurate.",
                    "type": "number"
                },
                "diskTotal": {
                    "description": "The total size of the normal data storage path for the OS, in bytes.\n\nOn Android it returns the disk space on the \"system\"\npartition holding the core Android OS.",
                    "type": "number"
                },
                "isVirtual": {
                    "description": "Whether the app is running in a simulator/emulator.",
                    "type": "boolean"
                },
                "manufacturer": {
                    "description": "The manufacturer of the device.",
                    "type": "string"
                },
                "memUsed": {
                    "description": "Approximate memory used by the current app, in bytes. Divide by\n1048576 to get the number of MBs used.",
                    "type": "number"
                },
                "model": {
                    "description": "The device model. For example, \"iPhone13,4\".",
                    "type": "string"
                },
                "name": {
                    "description": "The name of the device. For example, \"John's iPhone\".\n\nThis is only supported on iOS and Android 7.1 or above.",
                    "type": "string"
                },
                "operatingSystem": {
                    "$ref": "#/definitions/OperatingSystem",
                    "description": "The operating system of the device."
                },
                "osVersion": {
                    "description": "The version of the device OS.",
                    "type": "string"
                },
                "platform": {
                    "description": "The device platform (lowercase).",
                    "enum": [
                        "android",
                        "ios",
                        "web"
                    ],
                    "type": "string"
                },
                "realDiskFree": {
                    "description": "How much free disk space is available on the normal data storage, in bytes.",
                    "type": "number"
                },
                "realDiskTotal": {
                    "description": "The total size of the normal data storage path, in bytes.",
                    "type": "number"
                },
                "webViewVersion": {
                    "description": "The web view browser version",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "OperatingSystem": {
            "enum": [
                "android",
                "ios",
                "mac",
                "unknown",
                "windows"
            ],
            "type": "string"
        }
    }
}
@FreePhoenix888 FreePhoenix888 added the question Question about functionality label May 31, 2023
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 4, 2023

TypeDoc doesn't have functionality to do this today, so it'd have to be done with a plugin, which doesn't exist yet as far as I know

@FreePhoenix888
Copy link
Author

TypeDoc doesn't have functionality to do this today, so it'd have to be done with a plugin, which doesn't exist yet as far as I know

I have created a feature request: #2303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about functionality
Projects
None yet
Development

No branches or pull requests

2 participants