luttje / luttje/glua-api-snippets

`FCVAR_*` constants produce warnings for `CreateConVar`

Open
#88 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
45
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Doing something like:
```lua
CreateConVar("enable_the_thing", '1', FCVAR_REPLICATED)
```
... will make LuaLS erroneously produce a warning:
```
Cannot assign `integer` to parameter `(`FCVAR_ARCHIVE_XBOX`|`FCVAR_ARCHIVE`|`FCVAR_CHEAT`|`FCVAR_CLIENTCMD_CAN_EXECUTE`|`FCVAR_CLIENTDLL`...(+19))?`.
- `integer` cannot match `(`FCVAR_ARCHIVE_XBOX`|`FCVAR_ARCHIVE`|`FCVAR_CHEAT`|`FCVAR_CLIENTCMD_CAN_EXECUTE`|`FCVAR_CLIENTDLL`...(+19))?`
- Type `integer` cannot match `nil`
- Type `number` cannot match `nil`
- Type `integer` cannot match `number[]`
- Type `number` cannot match `number[]`
```

I can only assume that this is somehow because of either the type definition for `FCVAR`, or the type of the `FCVAR_*` constants.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the FCVAR type definition and FCVAR_* constants used by the generated Lua Language Server comments, then reproduce the CreateConVar example with LuaLS. Done means passing FCVAR_REPLICATED to CreateConVar no longer produces the reported type warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.