UrielCh / proxmox-api

TypeScript Api for proxmox
56 stars 15 forks source link

net[n] is typed only with net0, net1, net2, net3. #22

Open spenceradolph opened 1 year ago

spenceradolph commented 1 year ago

I am writing a script to assign network interfaces, however I noticed that the api documentation uses net[n] as the parameter. I confirmed that the api does take something like 'net4' when adding a 5th interface.

This does not seem possible with the current typing. Perhaps this could be covered with something like a template?

type netType = `net${number}`
type configObject = {
    [netName: netType]: string
}
const config: configObject = {
    'net2': 'test'
}
UrielCh commented 1 year ago

Yes, Typescript literal was not available then, but now that should work.

UrielCh commented 1 year ago

send me a code sample that causes the issue. or open a PR.