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

Fixed types generator #1325

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
71 changes: 44 additions & 27 deletions include/customDefinitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,22 +341,36 @@ interface Dragger extends Instance {
MouseDown(this: Dragger, mousePart: BasePart, pointOnMousePart: Vector3, parts: Array<BasePart>): void;
}

interface EditableImage extends Instance {
ReadPixels(this: EditableImage, position: Vector2, size: Vector2): Array<number>;
}
interface EmotesPages extends InventoryPages {}

interface EditableMesh extends DataModelMesh {
FindClosestPointOnSurface(this: EditableMesh, point: Vector3): LuaTuple<[number, Vector3, Vector3]>;
FindVerticesWithinSphere(this: EditableMesh, center: Vector3, radius: number): Array<number>;
GetAdjacentTriangles(this: EditableMesh, triangleId: number): Array<number>;
GetAdjacentVertices(this: EditableMesh, vertexId: number): Array<number>;
GetTriangleVertices(this: EditableMesh, triangleId: number): LuaTuple<[number, number, number]>;
GetTriangles(this: EditableMesh): Array<number>;
GetVertices(this: EditableMesh): Array<number>;
RaycastLocal(this: EditableMesh, origin: Vector3, direction: Vector3): LuaTuple<[number, Vector3, Vector3]>;
interface DrawImageTransformedOptions {
/**
* Specifies how the pixels of the source image blend with those of the destination.
* Default is `Enum.ImageCombineType.AlphaBlend`.
*/
CombineType: Enum.ImageCombineType.AlphaBlend;
/**
* Specifies the sampling method (e.g. Default for bilinear or `Pixelated` for nearest neighbor)
* Default is `Enum.ResamplerMode.Default`.
*/
SamplingMode: Enum.ResamplerMode.Default;
/**
* Specifies the pivot point within the source image for scaling and rotation.
* Default is the center of the source image (i.e. `Image.Size / 2`).
*/
PivotPoint: Vector2;
}

interface EmotesPages extends InventoryPages {}
interface EditableImage extends RBXObject {
DrawImageTransformed(
this: EditableImage,
position: Vector2,
scale: Vector2,
rotation: number,
image: EditableImage,
options: DrawImageTransformedOptions,
): void;
}

interface FloatCurve extends Instance {
GetKeyIndicesAtTime(this: FloatCurve, time: number): [before: number, after: number];
Expand Down Expand Up @@ -540,7 +554,23 @@ interface InsertService extends Instance {
GetUserSets(this: InsertService, userId: number): Array<SetInfo>;
}

interface Instance {
interface RBXObject {
/** `Instance.Changed` has been intentionally excluded from the roblox-ts type system to maintain soundness with the ValueBase objects.
* Please intersect your type with the `ChangedSignal` global type to unsafely access the `Instance.Changed` event.
* @example
* function f(p: Part) {
* (p as Part & ChangedSignal).Changed.Connect(changedPropertyName => {})
* }
*/
readonly Changed: unknown;
IsA<T extends keyof Instances>(this: Instance, className: T): this is Instances[T];
GetPropertyChangedSignal<T extends Instance>(
this: T,
propertyName: InstancePropertyNames<T>,
): RBXScriptSignal<() => void>;
}

interface Instance extends RBXObject {
/**
* **Clone** creates a copy of an object and all of its descendants, ignoring all objects that are not [Archivable](https://developer.roblox.com/en-us/api-reference/property/Instance/Archivable). The copy of the root object is returned by this function and its [Parent](https://developer.roblox.com/en-us/api-reference/property/Instance/Parent) is set to nil.
*
Expand All @@ -554,22 +584,13 @@ interface Instance {
* Clone will return nil if the root object has Archivable set to false.
*/
Clone<T extends Instance>(this: T): T;
/** `Instance.Changed` has been intentionally excluded from the roblox-ts type system to maintain soundness with the ValueBase objects.
* Please intersect your type with the `ChangedSignal` global type to unsafely access the `Instance.Changed` event.
* @example
* function f(p: Part) {
* (p as Part & ChangedSignal).Changed.Connect(changedPropertyName => {})
* }
*/
readonly Changed: unknown;
GetActor(this: Instance): Actor | undefined;
GetChildren(this: Instance): Array<Instance>;
GetDescendants(this: Instance): Array<Instance>;
GetTags(this: Instance): Array<string>;
FindFirstChild(this: Instance, childName: string | number, recursive?: boolean): Instance | undefined;
WaitForChild(this: Instance, childName: string | number): Instance;
WaitForChild(this: Instance, childName: string | number, timeOut: number): Instance | undefined;
IsA<T extends keyof Instances>(this: Instance, className: T): this is Instances[T];
FindFirstAncestorWhichIsA<T extends keyof Instances>(this: Instance, className: T): Instances[T] | undefined;
FindFirstChildWhichIsA<T extends keyof Instances>(
this: Instance,
Expand All @@ -578,10 +599,6 @@ interface Instance {
): Instances[T] | undefined;
FindFirstAncestorOfClass<T extends keyof Instances>(this: Instance, className: T): Instances[T] | undefined;
FindFirstChildOfClass<T extends keyof Instances>(this: Instance, className: T): Instances[T] | undefined;
GetPropertyChangedSignal<T extends Instance>(
this: T,
propertyName: InstancePropertyNames<T>,
): RBXScriptSignal<() => void>;
GetAttribute(this: Instance, attribute: string): AttributeValue | undefined;
SetAttribute(this: Instance, attribute: string, value: AttributeValue | undefined): void;
GetAttributes(this: Instance): Map<string, AttributeValue>;
Expand Down
3 changes: 3 additions & 0 deletions include/lua.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ declare namespace math {
/** Returns -1 if `x < 0`, 0 if `x == 0`, or 1 if `x > 0`. */
function sign(n: number): -1 | 0 | 1;

/** Maps a number from one range to another. */
function map(x: number, inmin: number, inmax: number, outmin: number, outmax: number): number;

/** Returns the sine of x (assumed to be in radians). */
function sin(n: number): number;

Expand Down
133 changes: 128 additions & 5 deletions include/roblox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ type ChangedSignal = {

type Tweenable = number | boolean | CFrame | Rect | Color3 | UDim | UDim2 | Vector2 | Vector2int16 | Vector3;

type ContentId = string;

interface EmoteDictionary {
/** When these arrays have more than one emote id in them, it will randomly select one of the emotes to play from the list. */
[emoteName: string]: Array<number>;
Expand Down Expand Up @@ -267,22 +265,47 @@ interface BundleInfo {

type TeleportData = string | number | boolean | Array<unknown> | Map<unknown, unknown>;

interface GameJoinContext {
JoinSource: Enum.JoinSource;
ItemType?: Enum.AvatarItemType;
AssetId?: string;
OutfitId?: string;
AssetType?: Enum.AssetType;
}

interface PlayerJoinInfo {
/** The `DataModel.GameId` of the experience the `Player` teleported from. Only present if the player teleports to the current experience and if a server calls the teleport function. */
SourceGameId?: number;
/** The `DataModel.PlaceId` of the place the `Player` teleported from. Only present if the player teleports to the current place and a server calls the teleport function. */
SourcePlaceId?: number;
/** The `Player.UserId` of the player who invited the current player to the experience. Use this data to identify the referrer and trigger reward logic. */
ReferredByPlayerId?: number;
/** An array containing the `UserId` numbers of the users teleported alongside the `Player`. Only present if the player teleported as part of a group. */
Members?: Array<number>;
/** Reflects the `teleportData` specified in the original teleport. Useful for sharing information between servers the player teleports to. Only present if `teleportData` was specified and a server calls the teleport function. */
TeleportData?: TeleportData;
/** A string containing launch data specified in the URL the player clicks to join the experience. Only present if the URL contains launch data. */
LaunchData?: string;
/** A dictionary that includes relevant information based on the context of the game join. */
GameJoinContext?: GameJoinContext;
}

interface BoundActionInfo {
/** Describes whether a touch button should be created on TouchEnabled devices */
createTouchButton: boolean;
/** The description of action set by SetDescription */
description?: string;
/** The title of the action set by SetTitle */
title?: string;
/** The image of the action's touch button set by SetImage */
image?: string;
/** The input types passed to BindAction for which this action will trigger */
inputTypes: Array<Enum.KeyCode | Enum.PlayerActions | Enum.UserInputType | string>;
/** Describes the priority level of the action.
* Priority level will still be included even if `BindActionAtPriority` wasn't used - by default it will be 2000.
*/
priorityLevel: number;
/** Describes the index of the action on the stack (increasing) */
stackOrder: number;
}

Expand Down Expand Up @@ -1962,11 +1985,17 @@ interface Path2DControlPoint {
* @deprecated
*/
readonly _nominal_Path2DControlPoint: unique symbol;
/** The position of the `Path2DControlPoint`. */
/**
* The position of the `Path2DControlPoint`.
*/
Position: UDim2;
/** The left tangent of the `Path2DControlPoint`. */
/**
* The left tangent of the `Path2DControlPoint`.
*/
LeftTangent: UDim2;
/** The right tangent of the `Path2DControlPoint`. */
/**
* The right tangent of the `Path2DControlPoint`.
*/
RightTangent: UDim2;
}

Expand Down Expand Up @@ -2410,6 +2439,42 @@ interface UDim2Constructor {

declare const UDim2: UDim2Constructor;

// ContentId
interface ContentId {
PepeElToro41 marked this conversation as resolved.
Show resolved Hide resolved
/**
* **DO NOT USE!**
*
* This field exists to force TypeScript to recognize this as a nominal type
* @hidden
* @deprecated
*/
readonly _nominal_ContentId: unique symbol;
/**
* An empty Content value with Content.SourceType of None.
*/
readonly none: ContentId;
PepeElToro41 marked this conversation as resolved.
Show resolved Hide resolved
/**
* The source type of the contained value.
*/
readonly SourceType: Enum.ContentSourceType;
/**
* A URI `string` if `Content.SourceType` is Uri, otherwise `nil`.
*/
readonly Uri?: string;
/**
* A reference to a non-nil `Object` if `Content.SourceType` is Object, otherwise `nil`.
*/
readonly Object?: RBXObject;
}

interface ContentIdConstructor {
fromUri: (uri: string) => ContentId;
fromObject: (object: RBXObject) => ContentId;
}

// Changed to `Content` instead of `ContentId`, that's how it's constructed
declare const Content: ContentIdConstructor;

// Vector2
interface Vector2 {
/**
Expand Down Expand Up @@ -2850,6 +2915,64 @@ declare namespace buffer {
function fill(b: buffer, offset: number, value: number, count?: number): void;
}

interface vector {
PepeElToro41 marked this conversation as resolved.
Show resolved Hide resolved
/**
* **DO NOT USE!**
*
* This field exists to force TypeScript to recognize this as a nominal type
* @hidden
* @deprecated
*/
readonly _nominal_vector: unique symbol;
}

declare namespace vector {
/** Constant vector with all components set to zero. */
const zero: vector;

/** Constant vector with all components set to one. */
const one: vector;

/** Creates a new vector with the given component values. */
function create(x: number, y: number, z: number): vector;

/** Calculates the magnitude of a given vector. */
function magnitude(vec: vector): number;

/** Computes the normalized version (unit vector) of a given vector. */
function normalize(vec: vector): vector;

/** Computes the cross product of two vectors. */
function cross(vec1: vector, vec2: vector): vector;

/** Computes the dot product of two vectors. */
function dot(vec1: vector, vec2: vector): number;

/** Computes the angle between two vectors in radians. The axis, if specified, is used to determine the sign of the angle. */
function angle(vec1: vector, vec2: vector, axis?: vector): number;

/** Applies `math.floor` to every component of the input vector. */
function floor(vec: vector): vector;

/** Applies `math.ceil` to every component of the input vector. */
function ceil(vec: vector): vector;

/** Applies `math.abs` to every component of the input vector. */
function abs(vec: vector): vector;

/** Applies `math.sign` to every component of the input vector. */
function sign(vec: vector): vector;

/** Applies `math.clamp` to every component of the input vector. */
function clamp(vec: vector, min: vector, max: vector): vector;

/** Applies `math.max` to the corresponding components of the input vectors. Equivalent to `vector.create(math.max((...).x), math.max((...).y), math.max((...).z))`. */
function max(...vecs: Array<vector>): vector;

/** Applies `math.min` to the corresponding components of the input vectors. Equivalent to `vector.create(math.min((...).x), math.min((...).y), math.min((...).z))`. */
function min(...vecs: Array<vector>): vector;
}

interface GettableCores {
AvatarContextMenuEnabled: boolean;
PointsNotificationsActive: boolean;
Expand Down
Loading
Loading