Skip to content

Releases: Benjamin-Dobell/tts-types

EmmyLua IDEA 201 (2020.1) - Forked 1.3.3 v2

31 May 17:48
Compare
Choose a tag to compare

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 a nil 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 away nil 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 subtracting nil, the IDE will see the updated type no worries.

  • Made function covariant of fun(...: 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 type table<string, number>, rather than simply table.

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

https://github.com/Benjamin-Dobell/IntelliJ-EmmyLua/tree/1395511874a36503002e5a2bc23ea7b05d0b7b83

Installation

See previous release notes.

EmmyLua IDEA 201 (2020.1) - Forked 1.3.3 v1

15 May 11:08
Compare
Choose a tag to compare

Installation

To install the .zip you'll need to go to IntelliJ's...

Preferences -> Plugins -> Settings Cog Icon -> Install Plugin from Disk...

Screen Shot 2020-05-15 at 9 20 52 pm

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

Screen Shot 2020-05-15 at 9 19 27 pm

Source

Source for this build is available at Benjamin-Dobell/IntelliJ-Luanalysis@c48c6ae

Can be built from the above source with:

./gradlew build_201