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

Supply DM types the Instance.Name string literal #613

Open
lolmanurfunny opened this issue May 11, 2024 · 0 comments
Open

Supply DM types the Instance.Name string literal #613

lolmanurfunny opened this issue May 11, 2024 · 0 comments

Comments

@lolmanurfunny
Copy link

When using the studio companion plugin, the Instance.Name string literal is currently discarded and therefore never able to be taken advantage of for type refinement.

Suppose I have two models in the workspace, foo and bar, and a function that accepts either one of them.

type foo = typeof(workspace.foo)
type bar = typeof(workspace.bar)

local function baz(model: foo | bar)
    if model.Name == "foo" then
        -- model's type is `foo | bar`, should be `foo`
    else
        -- model's type is `foo | bar`, should be `bar`
    end
end

In order to differentiate foo from bar at runtime, you'd use their names - that's sorta the point. However, the typechecker is unable to use this information since the .Name property is typed as just string.

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

No branches or pull requests

1 participant