Closed jakubg1 closed 2 years ago
---@class is simply misplaced
local class = require "class"
---@class Car
---@overload fun():Car 'to make the class callable'
local Car = class:derive("Car")
function Car:new()
self.engineRunning = false
end
--- Ignites this car.
---@param parameter boolean: A dummy parameter which has absolutely no use.
function Car:ignite(parameter)
self.engineRunning = true
end
--- Returns `true` if this car's engine is running.
function Car:getEngineRunning()
return self.engineRunning
end
return Car
It's working now. Thank you so much!
Hello, I apologize if the following issue has been already mentioned somewhere. I've been searching through the results, however none of them fully described a problem nor any solution helped.
First of all, I have three files (plus a batch script to run the code) of the following contents:
main.lua
Car.lua
class.lua
: a straight up copy of this file: https://github.com/bncastle/love2d-tutorial/blob/Episode4/class.luaBrief description so it's not that dry.
Car.lua
defines aCar
class which contains simple functions involving altering its state.main.lua
creates an object of typeCar
and does stuff on it. Andclass.lua
is just an OOP juice.After opening these in Visual Studio Code,
main.lua
gives warnings:It seems that it can't find a class associated with that variable, despite giving it a
---@type
indicator. I'd expect it to look something like that, along with proper autocompletion:Now, is this my omission, is it a bug, or is it a thing that is just not implemented? Or maybe something else? I'd be glad to provide more information if needed, or tell me what I need to change/fix.
Thank you in advance!