Git Product home page Git Product logo

roblox-ts.com's Introduction

roblox-ts.com

Contributions to the roblox-ts documentation are welcome!

All docs can be found within the docs folder, which are markdown files.

Local Development

  1. npm install
  2. npm start

To build the interactive playground:

  1. cd ./rbxts-worker
  2. npm install
  3. cd ..
  4. npm run start:playground

This command starts a local development server and open up a browser window.

Most changes are reflected live without having to restart the server.

roblox-ts.com's People

Contributors

asmeili avatar catgirlinspace avatar dionysusnu avatar emre1791 avatar kekidev avatar louiek22 avatar noah-haf avatar osyrisrblx avatar rimuy avatar rudy-dev avatar suyoin avatar tayiorrobinson avatar xethlyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

roblox-ts.com's Issues

Need documentation with iterators

A guide/documentation should be created to explain how iteration works in Roblox-ts. This is super confusing as it currently is, since typescript will function differently by indexing at 0.

An example of confusing code would be how ipairs functions:
https://roblox-ts.com/playground/#code/JYWwDg9gTgLgBAbzgdWgawM5gIYGMCmcAvnAGZQQhwBEAAlAEYAeMGA9BvlAG7AEbUA3AChhuCADsM8ENjAY4AXhTosefADoA4vhgBhABbAANgBMo+CQAoAlCOGlocK+KnwA2sAmn8TADRwXtLYEgQAunAQpIE4wFAYVrLyNjaIwnAZcGBQXjCJchie3r5hqWxscDBGCsAKAO4UEgDmwkSijlDOrtJwRT7+gW4h4ZHRwLHx+cmpCOmZ2blThV79cAC0cACMpXDlldVwdaoA-K3tTi6SPX2+AUEww-gRUTHYcQlJGClpmVk5EnkVr4yhUqrVAgock0DDBWkA

It would be nice to see a return of a guide similar to this old iteration guide and talk about how Roblox-TS handles iteration in-depth (ie. mention that ipairs has raw access with indices).

Documentation Requests

  • Runtime type checking with typeof and instanceof
  • Creating and manipulating Roblox Instances, indexing instances with .
  • Word of warning about misusing type assertions
  • typeIs
  • fspawn

Document new NPM package flow

Stuff that we might need to mention:

  1. How are NPM packages used within Roblox-TS to enhance the user's experience;
  2. The @rbxts scope and organization, and how to join it;
  3. Make use of the rbxtsc --init package feature;
  4. Among other info that needs to be updated.

Try/Finally not rethrowing error

AFAIK try/finally without catch should rethrow the error.

Link to current behaviour - if there's an error, it will be silently ignored.

In JS it's expected that it does rethrow (after running the finally block)

$ node -e "try {if(Math.random() > 0.5) {throw new Error('asdf');} console.log('not fail')} finally {console.log('finished')}"
finished
[eval]:1
try {if(Math.random() > 0.5) {throw new Error('asdf');} console.log('not fail')} finally {console.log('finished')}
                              ^

Error: asdf
    at [eval]:1:37
    at runScriptInThisContext (node:internal/vm:144:10)
    at node:internal/process/execution:109:14
    at [eval]-wrapper:6:24
    at runScript (node:internal/process/execution:92:62)
    at evalScript (node:internal/process/execution:123:10)
    at node:internal/main/eval_string:51:3

Node.js v20.10.0

In roblox-ts:

function TS.try(func, catch, finally)
	local err, traceback
	local success, exitType, returns = xpcall(
		func,
		function(errInner)
			err = errInner
			traceback = debug.traceback()
		end
	)
	if not success and catch then
		local newExitType, newReturns = catch(err, traceback)
		if newExitType then
			exitType, returns = newExitType, newReturns
		end
	end
	if finally then
		local newExitType, newReturns = finally()
		if newExitType then
			exitType, returns = newExitType, newReturns
		end
	end
	return exitType, returns
end

I believe it should check if not success and not catch, rethrow. Similarly for the async version.

Sometimes this behaviour is necessary: https://stackoverflow.com/a/2614484

Roact example for functional component

roblox-ts also allows for functional components, but no examples can be currently found in the Roact docs.

It would be nice to demonstrate a functional component, especially if it demonstrates how to pass [Roact.Children].

Add a discrepancies page to the documentation

There are a few behavioural discrepancies that need to be clarified due to the differences between how ECMAScript and Lua define their respective behaviours. These discrepancies could cause developers to encounter difficult-to-diagnose bugs in their code. Adding a page that lists differences in behaviour between roblox-ts and ECMAScript and roblox-ts and Lua would alleviate this issue by making any "quirks" known. Methods to get "expected" behaviour, if any, could be mentioned in addition to listing the differences, improving the developer experience.

Edit: Lua is used as shorthand for Lua 5.1 and, by extension, Luau, as Luau keeps near-perfect compatibility with the former.

Documentation Todo List

  • How all Roblox types are ambient BasePart, etc.
  • Macro math stuff for Vector3, CFrame, etc.
  • . vs : for function calls
  • Why RemoteEvent.OnServerEvent has unknown arguments

Playground auto-downloading breaks on other package import

The package @rbxts/yield-for-tree has the following index.d.ts:

export { EvaluateInstanceTree, yieldForTree, yieldForTree as default } from "@rbxts/validate-tree";

The playground incorrectly assumes that any import/export from another file must be a relative file reference. This breaks for yield-for-tree, when it tries to download https://cdn.jsdelivr.net/npm/@rbxts/yield-for-tree@latest/@rbxts/validate-tree.d.ts.

We should have a "getting started with TypeScript" page

We should have a "getting started with TypeScript" page. This should link the TypeScript handbook, as well as any other relevant references. It should also contain a guide (or link to one) for how to install tslint/prettier. (Should we switch to typescript-eslint now?)

Also, we should warn developers about the type system: The more you lie, the more unsafe your types are! I have seen a number of new roblox-ts developers, presumably having their first experience with the TS type system, and they have tons of type assertions and nonNullAssertions. In one case (that happened a few hours ago), I could point out an easily recognizable type error that could occur at run-time, which TS couldn't save them from because they used the nonNullAssertion operator because they didn't understand why they couldn't access any members of a nullable type.

If we had some super basic information with screenshots, I honestly believe it could help people. We could give an example like this:

image

When the mouse cursor is placed over a variable or identifier in VSCode, it will display its type. Types can change depending on the flow of the program. In this case, we see that Player.Character, put into the character variable yields the type Model | undefined, meaning it is either a Model Instance or nil. However, TS knows that after we check if (character), the character variable won't be undefined. In other words, it will be Model.

Unsupported Features

  • any
  • null
  • non-@rbxts packages
  • typeof on values
  • getters/setters
  • destructuring in a function call not at the end

V3: Datatype math changes

V3 adds a new way to define custom math methods on objects via a series of macro types (roblox-ts/roblox-ts#2015). This change should be documented, and ideally a guide on using them should be added to help people typing Lua packages that use these metamethods.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.