rbxts-flamework / core

Flamework is an extensible game framework. It requires typescript and offers many useful features.
MIT License
101 stars 8 forks source link

Networking type guard generation treats overloads as unions #24

Closed Fireboltofdeath closed 2 years ago

Fireboltofdeath commented 2 years ago
interface MyObject {
  a: string,
  b: number,
}

interface ServerEvents {
  myEvent<T extends keyof MyObject>(key: T, value: MyObject[T]): void;
}

myEvent("a", 15); // invalid, but passes
myEvent("b", "string"); // invalid, but passes

myEvent("a", "string"); // valid
myEvent("b", 15); // valid
myEvent("c", 15); // invalid
Fireboltofdeath commented 2 years ago

Flamework's typings don't support overloads, so closing this indefinitely