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

Matter setup routes does not compile in roblox-ts #8

Closed
littletsu opened this issue Feb 5, 2024 · 1 comment · Fixed by #10
Closed

Matter setup routes does not compile in roblox-ts #8

littletsu opened this issue Feb 5, 2024 · 1 comment · Fixed by #10
Labels
bug Something isn't working

Comments

@littletsu
Copy link
Contributor

In the typescript documentation for Matter setup the following routes.ts is recommended:

import { Route } from "@rbxts/yetanothernet";

const defaultConfiguration = {
  Channel: "Reliable",
  Event: "default",
}

// Replicate Matter Components
const MatterReplication = new Route(defaultConfiguration);

// Signal that the Player has loaded
const PlayerLoaded: Route<[boolean]> = new Route(defaultConfiguration);

export = {
  MatterReplication: MatterReplication,
  PlayerLoaded: PlayerLoaded,
}

This results in the following error by default: Argument of type '{ Channel: string; Event: string; }' is not assignable to parameter of type 'Configuration'. Types of property 'Channel' are incompatible. Type 'string' is not assignable to type '"Reliable" | "Unreliable" | undefined'.

I fixed this by moving the Configuration type to the Net namespace

declare namespace Net {
    const server: "NET_SERVER";
    
    type Configuration = {
        Channel: "Reliable" | "Unreliable" | undefined,
        Event: string | undefined,
    }
...

and make the defaultConfiguration use this type

import { Route, Configuration } from "@rbxts/yetanothernet";

const defaultConfiguration: Configuration = {
	Channel: "Reliable",
	Event: "default",
};

// Replicate Matter Components
const MatterReplication = new Route(defaultConfiguration);

// Signal that the Player has loaded
const PlayerLoaded: Route<[boolean]> = new Route(defaultConfiguration);

export = {
	MatterReplication: MatterReplication,
	PlayerLoaded: PlayerLoaded,
};
@YetAnotherClown YetAnotherClown added the bug Something isn't working label Feb 5, 2024
@YetAnotherClown
Copy link
Owner

Your fix looks good for this, would you like to make a PR for this? If not, I can push a fix later today myself.

@littletsu littletsu mentioned this issue Feb 5, 2024
@YetAnotherClown YetAnotherClown linked a pull request Feb 5, 2024 that will close this issue
YetAnotherClown pushed a commit that referenced this issue Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants