wartoshika / wow-declarations Goto Github PK
View Code? Open in Web Editor NEWTypescript declarations for the current live World of Warcraft Retail LUA API
License: MIT License
Typescript declarations for the current live World of Warcraft Retail LUA API
License: MIT License
Hi,
I've wrote a a sample of the issue I found with methods that suppose to return a tuple in lua.
typescript source
export class App {
constructor() {
print("Hello World of Warcraft", "This is my Typescript addon!");
const frame = CreateFrame("Frame", null, UIParent);
frame.SetScript("OnUpdate", (frame, elapsed) => {
let test = GetActionCooldown(1);
print(`${test[0]}, ${test[1]}, ${test[2]}`);
});
frame.Show();
}
}
lua result
function App.__init(self)
print("Hello World of Warcraft", "This is my Typescript addon!")
local frame = CreateFrame("Frame", nil, UIParent)
frame:SetScript("OnUpdate", function (frame, elapsed)
local test = GetActionCooldown(1)
print("" .. tostring(test[(tonumber(0) + 1)]) .. ", " .. tostring(test[(tonumber(1) + 1)]) .. ", " .. tostring(test[(tonumber(2) + 1)]) .. "")
end)
frame:Show()
end
Expected behaviour:
Lua Transpiler convert typescript tuple properly (I actually have no clue since you will need to give X different variable name from the typescript tuple (array)
Thanks
UPDATE:
I found the solution, I didn't know you could do this in typescript:
let [start, duration, enable] = GetActionCooldown(1);
print(`${start}, ${duration}, ${enable}`);
This is very much a suggestion/topic for discussion only..
Consider exporting this with the wow api version
i.e.
If we are on WoW api 8.2.0
then versions could be 8.2.0.1
, 8.2.0.13
, etc
I noticed all interfaces are prefixed with Wow<decl>
, would you be interested in migrating to a WoWAPI
namespace instead? It'll end up cleaner in my opinion. For reference, check out how I do it: https://github.com/martinjlowm/types-wow-api/blob/master/src/widgets/frame.d.ts
Your declaration collection seems more complete than mine, so I'm willing to help migrating existing types to this namespaced approach.
As a bonus it enables the use of WoWAPI.Object
, which, within the namespace, can be referenced directly as Object
, which will not interfere with JavaScript's declaration.
I am currently using these types with TypeScriptToLua, they are so so helpful, thanks!
Would you, or have you considered naming @types/wow-declarations
? It would require no tsconfig.json
update if this was rooted in @types/
because the default typeRoots includes anything with @types/**/*
Are you using Prettier etc?
Can you commit your settings.json
or .prettierrc
so that auto formatting settings are declared in the repo?
I am trying to create minimal diffs but every time I save it's reformatting..
Seems like you have this:
settings.json:
{
"editor.tabSize": 4,
"files.trimFinalNewlines": false,
"files.trimTrailingWhitespace": false,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Any plans for updates for shadowlands?
There's quite a few functions/constants/etc that are not included in the WoWAPI namespace, and as a result they don't appear to be usable.
I have wow declarations defined in tsconfig:
"typeRoots": [
"node_modules/@wartoshika/wow-declarations/declarations",
"node_modules/lua-types/5.1"
],
For example, CreateFrame
(from ui.d.ts
is not resolvable.
Full project is here: https://github.com/Brusalk/tsCoolDown
The fix for error TS2304: Cannot find name 'AtlasID'.
is not pushed to npm despite the version being the same as the release in github.
(See 0e4b87d)
Please provide this fix to npm users as well, thank you.
I can't seem to find any typing for the SlashCmdList object used to register slash commands. Did I miss this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.