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

merge with rbx-safe-types #66

Merged
merged 14 commits into from
May 28, 2019
Merged

merge with rbx-safe-types #66

merged 14 commits into from
May 28, 2019

Conversation

Validark
Copy link
Contributor

@Validark Validark commented May 9, 2019

  • Removes arbitrarily indexing instances. Here are two built-in alternatives, but one could also throw together a library pretty quickly which can take in an arbitrary number of strings and spit out an Instance. Perhaps we may add a built-in function as we did for typeIs/opcall and it could be transpiled to a series of dot-operator accesses.
const Workspace = game.GetService("Workspace");
const ReplicatedStorage = game.GetService("ReplicatedStorage");
 
// bad practice, and disallowed in rbx-safe-types:
const myPart = Workspace.Maps.Valiant.Houses;
 
// safer, won't ever have property conflicts, etc.
const houses = Workspace
    .FindFirstChild("Maps")!
    .FindFirstChild("Valiant")!
    .FindFirstChild("Houses")!;
 
// Another alternative is using unioned types:
interface RemotesChildren {
    Chatted: RemoteEvent;
    Attacked: RemoteEvent;
    Usurped: RemoteEvent & {
        ShouldReplicate: BoolValue;
    };
}
 
const remoteFolder = ReplicatedStorage.WaitForChild("Remotes") as Folder & RemotesChildren;
print(remoteFolder.Chatted); // exists! Chatted is a RemoteEvent
print(remoteFolder.Usurped.ShouldReplicate.Value); // TS knows that .Value is a boolean!
  • Adds a ton of extra type information relating to objects, what kind of Instances things are, BrickColors, etc

  • Adds the ability to pull documentation from the JSON pages the roblox wiki uses to generate their pages

  • Switches to an Enum system where Enums are real objects of the form { Name: stringLiteral, Value: numberLiteral, EnumType: EnumType }. This means that their Name and Value properties are immutable.
    image

  • Maintains all previous type data and information, doesn't make any changes to the es.d.ts lib. This PR does not include changing array indexing types.

  • Removes manual.d.ts in favor of customDefinitions.d.ts. customDefinitions is not bundled with npm releases, but rather, its information is copied directly into generated_classes.d.ts.

Closes #33
Closes #37
Closes #53
Closes #65
Closes #69
Closes #71
Closes #73
Closes #74

  • Temporarily removes @rbxts server/client directives from Services (ReplicatedStorage, ServerStorage, etc). This is because the transpiler will need to get code which exempts ClassName from being detected as a server-only or client-only property.

Update

  • Makes it so every interface is flatly named. No Rbx_, RbxInternal, or DerivesFrom.
  • Gives every Instance a ClassName property, which can be used to narrow via the added function isClassName.
  • Removed the unnecessary numeric rgb data from the BrickColor implementation. Also shortened BrickColor names so it displays more readable information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment