roblox-ts / types Goto Github PK
View Code? Open in Web Editor NEWTypeScript typings for the Roblox platform. Partially handwritten and partially automatically generated.
Home Page: https://www.npmjs.com/package/@rbxts/types
License: MIT License
TypeScript typings for the Roblox platform. Partially handwritten and partially automatically generated.
Home Page: https://www.npmjs.com/package/@rbxts/types
License: MIT License
Rbx-types says that the senderPlayer parameter is a Instance
and the recipientIds parameter is any[]
, while the documentation says senderPlayer is a Player
and receipientIds is number[]
.
xpcall not exists
This was my fault. I didn't that much about it.
Promise.resolve(); // actually: error
// expected: no error
let prom:Promise<void> = Promise.reject('asdfasdf'); // actually: error
// expected: no error
Currently, the Object.keys/values/entries
functions don't have the best types for our purposes. I wrote this up and thought we could use something similar to this in es.d.ts
once #66 gets merged.
declare function keys<T>(o: Array<T>): Array<number>;
declare function keys<T>(o: Set<T>): Array<T>;
declare function keys<K, V>(o: Map<K, V>): Array<K>;
declare function keys<T>(o: T): Array<keyof T>;
declare function values<T>(o: Array<T>): Array<T>;
declare function values<T>(o: Set<T>): Array<true>;
declare function values<K, V>(o: Map<K, V>): Array<V>;
declare function values<T>(o: T): Array<T[keyof T]>;
declare function entries<T>(o: Array<T>): Array<[number, T]>;
declare function entries<T>(o: Set<T>): Array<[T, true]>;
declare function entries<K, V>(o: Map<K, V>): Array<[K, V]>;
declare function entries<T>(o: T): Array<[keyof T, T[keyof T]]>;
Signature should match Promise.then
Like the title suggests, these methods are not defined in rbx-types, even though their respective 'add' methods are.
E.g.:
new UDim2(3, 3, 3, 3).add(new UDim2(2, 2, 2, 2));
works just fine, while
new UDim2(3, 3, 3, 3).sub(new UDim2(2, 2, 2, 2));
gives the error "Property 'sub' does not exist on type 'UDim2'"
These should be implemented since they are part of the functionality of the respective types (see UDim and UDim2
3rd of NumberSequenceKeypoint is optional
NumberSequenceKeypoint Constructors
NumberSequenceKeypoint.new ( number time, number value )
--Creates a keypoint with a specified time and value.
NumberSequenceKeypoint.new ( number time, number value, number envelop )
--Creates a keypoint with a specified time, value, and envelope.
math.frexp shoule return tuple instead of array
expected>
local mantissa, exponent = math.frexp(v);
actually>
local _0 = math.frexp(v);
local mantissa, exponent = _0[1], _0[2];
global version
is a function which returns a string, not a string.
version: () => string
Adding a this
parameter would be a quick and easy way of ensuring that object methods are never called improperly.
Example:
const { FindFirstChild } = part;
FindFirstChild("Hello");
// ERROR: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Instance'.
Every method should be assigned a this
which is the class in which it is defined. E.g.
Camera.GetTiltSpeed(): number
// should be
Camera.GetTiltSpeed(this: Camera): number
GuiService
UserInputService
MessagingService
GroupService
TextService.FilterStringAsync
AssetService
Here is the proper definition I came up with:
type GetProperties<T> = {
[Key in keyof T]-?: Key extends "GetPropertyChangedSignal"
? never
: T[Key] extends RBXScriptSignal
? never
: (() => any) extends T[Key]
? never
: Key
}[keyof T];
GetPropertyChangedSignal<T extends GetProperties<this>>(property: T): RBXScriptSignal;
GameSettings, ParabolaAdornment, LuaSettings, PhysicsSettings, Player cannot be instantiated by Instance.new. Could we remove them from showing up in the prompts for new Instance("")
? It comes from CreatableInstances
from the wiki: If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil
Pages:GetCurrentPage()
currently returns unknown
.
Unfortunately, it's really hard to define this on a case-by-case basis. Lots of APIs use either Pages or a class that inherits from Pages.
We should convert the class to be a generic class (Rbx_Pages<T = unknown>
) so that we can override it per API.
The new type definition for Rbx_Pages.GetCurrentPage()
would look like:
interface Rbx_Pages<T = unknown> extends Rbx_Instance {
Rbx_Pages.GetCurrentPage(): T;
}
CFrame.toAxisAngle should return tuple instead of array
output>
local _0 = cframe:toAxisAngle();
local axis, theta = _0[1], _0[2];
I think it is sometimes useful to declare something as a ReadonlyMap/Set, but it would be better if I did not have to use new Map() as ReadonlyMap
. I would like to add a constructor to these objects so one can just do new ReadonlyMap()
directly.
Where we have generics in things like FindFirstChild, <T = Instance>
should be <T extends Instance = Instance>
, because it must always be an Instance.
For example:
Both CFrame:VectorToObjectSpace(Vector3))
and
CFrame:vectorToObjectSpace(Vector3)
are valid in engine, but only the latter spelling is supported by rbx-types.
string.byte needs to return tuple.
it returns number now.
declare namespace _Instances {
class _Instance {
private _0: never
Name: string
IsA(x: "Instance"): this is Instance
IsA(x: "Folder"): this is Folder
}
class _Folder extends _Instance {
private _1: never
}
}
interface Instance extends _Instances._Instance {}
interface Folder extends _Instances._Folder {}
const x = {} as Instance
if (x.IsA("Folder")) {
x // Folder
} else {
x // Instance
}
string.find, string.sub, etc.
Two new static constructors were added for UDim2 but they're not enabled yet.
This issue is a reminder to add them.
interface UDim2Constructor {
fromOffset(x: number, y: number): UDim2;
fromScale(x: number, y: number): UDim2;
}
customDefinitions.d.ts is not supposed to be bundled with rbx-types. Everything in it is already copied into generated_classes.d.ts
setmetatable
should be declared
BasePart.Touched
param #1 should be BasePart
GetPlayerFromCharacter
should return Player | undefined
(maybe also accept Model
?)
GetPlayerByUserId
should return Player | undefined
GetPlayers
should return Array<Player>
GetCharacterAppearanceAsync
should return Model | undefined
GetCharacterAppearanceInfoAsync
could have an interface made for the return type
GetFriendsAsync
should return FriendPages
GetUserThumbnailAsync
should return a typed tuple
GetTagged
could be GetTagged<T = Instance>(tag: string): Array<T>;
Should be
function traceback(message?: string, level?: number): string;
function traceback(thread: thread, message?: string, level?: number): string;
This is undocumented (unintentionally) - but basically is on parity with 5.1 debug.traceback ([thread,] [message [, level]])
now - according to @LPGhatguy
https://www.lua.org/manual/5.1/manual.html#pdf-debug.traceback
When I say import X and only use it in as typeof X
it compiles the import of X into lua (even though it's a type thing).
not sure if this is intentional, but it does not follow the unknown
rule that RemoteEvents seem to follow.
When calling os.date, it will currently always error if you don't use os.date("*t, x)
.
This means you can't use it in instances such as:
os.date("!*t") // Current date table in UTC time
os.date("%x") // Current date in MM/DD/YY format
This is among other alternatives as specified in the Lua documentation: https://www.lua.org/pil/22.1.html
All Instances are Folders, ValueBases, and a few other similar types. This is bad for a few reasons.
Example 1:
if (myInstance.IsA("Folder")) {
// Do something with folders
} else if (myInstance.IsA("Part"))
// Do something with parts
}
Example 1 will error on calling "IsA" in the else if clause, since it is of type "never" after it has been determined not to be a Folder (and since all Instances are Folders, it must not be an instance)
Example 2:
if (myInstance.IsA("Part")) {
// Do something with parts
} else if (myInstance.IsA("Folder"))
// Do something with folders
}
Example 2 works as a workaround for this issue in this case—however, this does not work if you have an "else" clause at the end, or are dealing with multiple all-encompassing types (like ValueBase with Folder)
Example 3:
if (myInstance.IsA("Folder")) {
// Do something with folders
} else {
print("Found another instance of type" + myInstance.ClassName)
}
Since all Instances are Folders, the example 3 will error, because "myInstance" is of type "never" in the else clause.
To work around this, you must use a type assertion (myInstance as Instance), or something similar, in clauses following all-encompassing type guards
This needs to be fixed for datastores to be usable
CFrame.Lerp is the title preferred by Roblox documentation. This makes functions expecting something with the "lerp" method unable to take Vector3, and functions expecting something with the "Lerp" method unable to take CFrame, despite the fact that these methods have identical signatures and (essentially the same) behavior.
Possible security levels:
"None" // Default
"LocalUserSecurity" // Command Line
"PluginSecurity" // Plugins
"RobloxScriptSecurity" // CoreScripts
"RobloxSecurity" // ?
"NotAccessibleSecurity" // ?
Higher security levels should include the next lower security level?
Then we can create something like plugin.d.ts
which links to include/PluginSecurity.d.ts
string.find/string.match should use LuaTuple
Lua supports multiple captures being returned using string.match, however here there is no return type for multiple captures.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.