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

the types library pollutes the globals #1564

Open
Ukendio opened this issue Dec 13, 2024 · 5 comments
Open

the types library pollutes the globals #1564

Ukendio opened this issue Dec 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Ukendio
Copy link

Ukendio commented Dec 13, 2024

I expect types to only be referenced and recognized as a global in type functions, however currently it shadows seemingly gets referenced anywhere; if this is an unrealistic expectation, I could change my code but I do have a lot of code that names variables types so it would be a shame.

@Ukendio Ukendio added the bug Something isn't working label Dec 13, 2024
@vegorov-rbx vegorov-rbx added the invalid This doesn't seem right label Dec 13, 2024
@vegorov-rbx
Copy link
Collaborator

There is no types library in the globals.

Marking as 'invalid'. Please provide more information about your issue before we close it.

@Ukendio
Copy link
Author

Ukendio commented Dec 13, 2024

Maybe I have an old version, but this seems like valid formed code to me

type function _Pair(first, second)
    local thing = first:components()[2]

	if thing:readproperty(types.singleton("__T")):is("nil") then
		return second
	else
		return first
	end
end

export type Pair<T, U> = _Pair<T, U>

type Test = Pair<Entity<nil>, Entity<Vector3>> -- Entity<Vector3> as expected

export type Entity<T = nil> = number & { __T: T }

I tested it against my cases and it worked

@vegorov-rbx
Copy link
Collaborator

Yes, that code is valid.
And it uses the types inside a type function, so I don't understand what issue you have with types library.

@Ukendio
Copy link
Author

Ukendio commented Dec 13, 2024

I am getting "shadowing variables" errors on variables outside of type functions that are named "types"
LocalShadow: Variable 'types' shadows a global variable used at line 1739

I can provide you the whole file if that helps, it is pretty large though!

@vegorov-rbx vegorov-rbx removed the invalid This doesn't seem right label Dec 13, 2024
@vegorov-rbx
Copy link
Collaborator

It would have been helpful to include that error message in your original issue description.
Thanks for clearing it up now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants