Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add declaration file for json.lua #1

Closed
wants to merge 5 commits into from
Closed

Add declaration file for json.lua #1

wants to merge 5 commits into from

Conversation

pdesaulniers
Copy link
Member

@pdesaulniers pdesaulniers commented Apr 5, 2020

Here's a very simple declaration file for json.lua, just in case you needed an example :)

An old version of the library can be found on LuaRocks.

TODO:

  • Add proper tests for the declaration file using busted (ideally, we should also be able to run busted at the root of the project to test all the declarations in the repo)
  • Add a .rockspec file so that the declaration can be installed using luarocks install @types/rxi-json-lua or something similar (not sure if LuaRocks would allow that name...)

@pdesaulniers pdesaulniers changed the title Break the ice with json.lua Add declaration file for json.lua Apr 5, 2020
@hishamhm
Copy link
Member

I've been slow to merge this because I've been thinking about how to organize modules here:

ideally, we should also be able to run busted at the root of the project to test all the declarations in the repo

I'm wondering if we should be using busted for testing the type declarations. The busted tests end up being more verbose than the type definitions themselves. Plus, this kind of unit tests don't really verify that the types match what the Lua modules actually do, and they mostly re-state what's being said in the .d.tl file. I'm thinking maybe something lighterweight such as just running tl check on the .d.tl file to verify that it is syntactically correct?

Add a .rockspec file so that the declaration can be installed using luarocks install @types/rxi-json-lua or something similar (not sure if LuaRocks would allow that name...)

types/rxi-json-lua would be valid if we created a types account, but we can figure that out later.

@pdesaulniers
Copy link
Member Author

pdesaulniers commented Apr 16, 2020

I'm thinking maybe something lighterweight such as just running tl check on the .d.tl file to verify that it is syntactically correct?

Yeah, that would be good enough for this library.

this kind of unit tests don't really verify that the types match what the Lua modules actually do, and they mostly re-state what's being said in the .d.tl file

I agree, this approach is not so great, but I figured it was better than nothing. I considered adding tests because some libraries can be pretty hard to type, and I wanted to make sure that every kind of function call in these libraries worked as intended. At least, these tests could be replaced by a simple test.tl file which contains example code for the library.

In some cases, I guess we could verify that the types match what the Lua modules actually do, but that wouldn't be very practical. We'd have to download tons of libraries and programs each time we run the tests from scratch :)

@hishamhm
Copy link
Member

I was just about to merge this (with the Busted tests removed), but I noticed another small issue to settle first: naming.

To avoid conflicts, I think we should go with the package directories as used in the root manifest repository of LuaRocksrxi-json-lua in this case, even though apparently that wasn't uploaded into LuaRocks by the original author (I can switch ownership to the original author if they are interested).

@pdesaulniers Sounds good?

PS: I added a comment at the json.lua repo: rxi/json.lua#13 (comment)

@pdesaulniers
Copy link
Member Author

@hishamhm Yes, that makes sense.

@hishamhm
Copy link
Member

Cool! Merged manually! We can address CI for tl checking the modules and rockspecs later.

@hishamhm hishamhm closed this Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants