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

[Question] Prefixing/modifying a generic to get a different class #1322

Closed
Ketho opened this issue Jul 11, 2022 · 1 comment
Closed

[Question] Prefixing/modifying a generic to get a different class #1322

Ketho opened this issue Jul 11, 2022 · 1 comment
Labels
enhancement New feature or request feat/generic Related to generic emulation feature

Comments

@Ketho
Copy link

Ketho commented Jul 11, 2022

In World of Warcraft we have a Frame class and a AceGUIFrame class, but the problem is they are created with CreateFrame("Frame") and AceGUI:Create("Frame") respectively.

How would I get AceGUI:Create("Frame") to return the AceGUIFrame class?

---@alias FrameType
---|"Frame"

---@class Frame
local Frame = {}
function Frame:SetToplevel(isTopLevel) end

---@generic T
---@param frameType `T` | FrameType
---@return T frame
function CreateFrame(frameType) end

local normalFrame = CreateFrame("Frame")
normalFrame:SetToplevel(true)
---@alias AceGUIContainerType
---|"Frame"

---@class AceGUIFrame
local AceGUIFrame = {}
function AceGUIFrame:SetTitle(text) end

local AceGUI = {}

---@generic T
---@param type `T` | AceGUIContainerType
---@return "AceGUI"..T
function AceGUI:Create(type) end

local aceguiFrame = AceGUI:Create("Frame")
aceguiFrame:SetTitle("Example")

Current behavior
image

Expected behavior
image

Original issue: Ketho/vscode-wow-api#43

@sumneko sumneko added the enhancement New feature or request label Jul 12, 2022
@sumneko
Copy link
Collaborator

sumneko commented Jul 12, 2022

Operations on types are currently not supported

@carsakiller carsakiller added the feat/generic Related to generic emulation feature label Jan 30, 2023
@Ketho Ketho closed this as not planned Won't fix, can't repro, duplicate, stale Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat/generic Related to generic emulation feature
Projects
None yet
Development

No branches or pull requests

3 participants
  翻译: