Changing game.Service name results in game:GetService failing type inference on modules

Wow what a long name for a title, anyhow I recently learned that changing the name of a service (whether through explorer or through console) can often cause issues on how the script editor handles modules.

For an example, I changed the name of ReplicatedStorage to ReplicatedContainer and insert a module in the service to be used by a script. Within the module it will define module.message = "hello world".
image

image

Now within the script in ServerScriptService, I will require this module to print out module.message. However, typecheck will instead consider it to be an unknown require. Of course, this now means that you will get zero autofill options or anything to assist with modules. I assume that this is not intended feature, and the only workaround would be setting the service’s back to their original name, but nonetheless I don’t believe that this should continue as-is.

1 Like

For some odd reason, it didn’t include the other screenshots, here they are:

image

I can’t repro this not working (and can be pretty sure it’s generally working because we rely on the same autocomplete for developing code internally).

What beta features / plugins do you have?

1 Like

The devices that I have tested this on have no beta features enabled. Nor is there any plugin modification. Perhaps there IS some sort of beta feature that could fix this? I should probably test the new Luau type solver and see if I can still replicate it there.

Something to note is that this issue only occurs when using game:GetService, getting the module in any other way doesn’t cause this issue. In my example, I can use game.ReplicatedContainer.Module and it works just fine.

Hi there, and thank you for the report! This is legitimately a bug in some sense, with the underlying cause being that the type system is looking up services based on their name in the data model when you do game:GetService, rather than by their instance type. We do not currently have any functionality in the type system that selects data model entries by their type, and frankly, the engineering effort involved in building that is not worth the payoff here. We don’t think there’s a very compelling reason to rename builtin services, so our suggested resolution to this issue is “don’t rename services if you want to both use game:GetService and have working autocomplete for those services.” Apologies that this is not likely to be a super satisfying answer, but we have a limited amount of time and engineering power, and have to make realistic judgments about things on our backlog that are just not ever going to be done.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.