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

变量类型声明 #14

Open
midgithub opened this issue Jan 22, 2019 · 0 comments
Open

变量类型声明 #14

midgithub opened this issue Jan 22, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@midgithub
Copy link

A.lua中

---@class A
local a = {}

--- @alias print fun():void
--- @desc 打印
--- @return void
function a.print()
end

return a

B.lua中

---@type A
local a = require "a"

---@see print
_G.print = a.print

在A.lua 中 查看函数的定义为
image

在B.lua 中 在 a.print处停留查看的信息为
image
在 _G.print 处查看定义为
image

想问问现有的机制中,如何才能让 _G.print处看到的定义 和 A.lua中还有B.lua中的 a.print处的一致

再延伸点
将一个写好emmylua注释标签的变量,作为等式左值赋值给等式右值。 左值能够用上右值的声明

期望的样子可能是:

  1. 针对上面的使用情景,类和类中的成员函数
---@type A#print
_G.print = a.print
  1. 或者更简单粗暴的, 直接等价于类型A,适用于所有类型的变量
---@aliasType A
_G.print = aDefinedFunValue
@tangzx tangzx added the enhancement New feature or request label Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants