Releases: Benjamin-Dobell/tts-types
EmmyLua IDEA 201 (2020.1) - Forked 1.3.3 v2
Changes
-
Made ---@type support a list of types
Particularly useful for type-casting multiple/variadic return values. -
Support for tuples (represented as a shapes with number literal keys) and improved type <-> "array" compatibility.
-
Better error reporting for "multiple results" e.g. functions that return multiple values.
-
Added support for
---@not ty, <ty, ...>
type casts i.e. subtracting types from a union. Particularly useful for casting away anil
from a type union e.g.---@return string|nil function maybeString() --[[...]] end ---@param str string function wantsString(str) end local result = maybeString() if result then wantsString(--[[---@not nil]] result) end
A
--[[---@type string]]
cast would work equally as well in the above example, however, when dealing with more complicated types (e.g. callback function types or a union of types), then writing them all out just to cast awaynil
is a pain. It's also safer just to subtract a type, because if an API changes to return a different value and you simply cast, the IDE won't be able to pickup on that. However, if you're just subtractingnil
, the IDE will see the updated type no worries. -
Made
function
covariant offun(...: any): any...
-
Return statements now support @type annotations. Useful when you're providing a generic callback. In the past you would have needed either a temporary variable or a type cast; neither of which are ideal e.g.
---@generic T ---@param builder fun(): T ---@return T function build(builder) return builder() end local stringNumberTable = build(function() ---@type table<string, number> return {a = 1} end)
stringNumberTable
will end up with the typetable<string, number>
, rather than simplytable
.
Fixes
- Fixed mainSignature return type inference.
- Fixed type checking of shapes within an array.
- Fixed lookup of "indexed" fields where aliases and/or unions are the index key type.
- Fixed array contravariance (base must be invariant)
- Fixed return type inspections for variadic return values.
Source
Installation
See previous release notes.
EmmyLua IDEA 201 (2020.1) - Forked 1.3.3 v1
Installation
To install the .zip
you'll need to go to IntelliJ's...
Preferences -> Plugins -> Settings Cog Icon -> Install Plugin from Disk...
Select the .zip
, then when prompted restart IntelliJ.
Note: You may be prompted to install an EmmyLua update. Please do not do so, this will revert you to the latest official release, which does not have the functionality necessary to utilise these Tabletop Simulator types.
.ttslua Extension
By default, EmmyLua expects Lua files to have the extension .lua
. If you wish to work with the .ttslua
extension then you can go to IntelliJ's
Preferences -> Editor -> File Types -> Lua Language
At the bottom of the "Registered patterns" list click the add ('+') icon and add the entry:
*.ttslua
Source
Source for this build is available at Benjamin-Dobell/IntelliJ-Luanalysis@c48c6ae
Can be built from the above source with:
./gradlew build_201