roblox-ts / roblox-ts.com

The roblox-ts website
https://roblox-ts.com
13 stars 41 forks source link

Add a discrepancies page to the documentation #129

Open dyslexicsteak opened 5 months ago

dyslexicsteak commented 5 months ago

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.

LouieK22 commented 5 months ago

I'd love to get this written up and documented. What are the specific discrepancies that need to be documented?

dyslexicsteak commented 5 months ago

I'd love to get this written up and documented. What are the specific discrepancies that need to be documented?

I'm not familiar with all the discrepancies; you'd have to ask @osyrisrblx.

LouieK22 commented 5 months ago

Planned documentation:

Dionysusnu commented 5 months ago

Maybe something about circular requires? (Node)JS handles them by filling in the export objects dynamically, but Roblox Luau requires that imports are returned all at once.

Also one for the list: Array and string lengths with .size() instead of .length

Dionysusnu commented 5 months ago

This one's niche, but maybe iteration order? JS defines it as property definition order, but Luau has random order with pairs or generalised iteration.

dyslexicsteak commented 5 months ago

This one's niche, but maybe iteration order? JS defines it as property definition order, but Luau has random order with pairs or generalised iteration.

If there's a difference it should be documented, it's seemingly a coin flip whether roblox-ts goes with the Lua behaviour or ECMAScript behaviour so I didn't comment on that.

Dionysusnu commented 5 months ago

Roblox-ts doesn't support for-in loops, so any object iteration goes through pairs, which ES obviously doesn't cover. That's why I'm conflicted on whether it belongs in this doc page, since it is consistent for pairs, just that pairs is not a default TS thing.