Skip to content

Does not use the re-assigned value type if it does not conform with the declared value type and is exported #466

Open
@PeterCardenas

Description

@PeterCardenas

Consider we have the following file:

-- a.lua
local M = {}
M.x = 1
M.x = ''
return M

And then we import it in another file:

-- b.lua
local a = require('a')
---@type string
local test = a.x

In a.lua we get a type error, which is somewhat ok since we never explicitly said if we wanted a union. However, the type of x should still be string since that is most correct. Inside of b.lua, a.x is an integer which results in a type error in b.lua, which is not correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions