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

Limit type visibility #3

Open
Benjamin-Dobell opened this issue Jul 13, 2020 · 1 comment
Open

Limit type visibility #3

Benjamin-Dobell opened this issue Jul 13, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Benjamin-Dobell
Copy link
Owner

Benjamin-Dobell commented Jul 13, 2020

The mere presence of a type in a project should not expose that type to every file i.e. types should not be global.

Luanalysis should (recursively EDIT: Recursively pulling in is a bad idea, don't do that) pull in types when it sees a require. Additionally, we should provide some mechanism to allow consumers to avoid type name collisions.

e.g.

local Map = require("Map")
local LibraryMap = require("library/Map") ---@prefix Library

---@type Map
local myMap = Map()

---@type LibraryMap
local libraryMap = LibraryMap()

Just a hypothetical solution, other languages allow individual types to be renamed. The above is fairly low friction though.

Additionally, we may want to define types that we never export to consumers i.e. consider adding local types like:

---@local alias Builder fun(): void
@Benjamin-Dobell
Copy link
Owner Author

If this was to go ahead, we'd also need something like:

---@require "some-userdata-type"
---@require "some-legacy-global"

To ensure that types that are available globally in a Lua context (not required) can be utilised.

Could see this becoming cumbersome in some environments though, so would be wise to offer some mechanism to import types project wide as well.

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

1 participant