Skip to content

Conversation

@andrewimeson
Copy link
Contributor

Prior to this it would only work if you did

NewDnsProvider("bind","BIND" {"stuff": "stuff"})

But it wouldn't support omitting the optional provider type and specifying the extra object.

NewDnsProvider("bind", {"stuff": "stuff"})

Fixes #3946

@andrewimeson
Copy link
Contributor Author

Downside: This does make the hinting less useful for NewDnsProvider().

Maybe there's another way to solve this.

image

@tlimoncelli
Copy link
Collaborator

A half-baked thought:

What if the parameters/parameter_types only reflected the modern style (NewDnsProvider("bind", {"stuff": "stuff"}) and NewDnsProvider("bind")). The code would still support the old style (NewDnsProvider("bind", "BIND", {"stuff": "stuff"}) and the docs could have a section that explains that that format works but should be updated.

While I'm always concerned about backwards compatibility, I have little sympathy for people that have been ignoring a warning for more than a year. They've been getting warnings that look like this:

INFO: In dnsconfig.js NewDnsProvider("foo", "BAR") can be simplified to NewDnsProvider("foo") (See https://docs.dnscontrol.org/commands/creds-json#cleanup)

The docs say "Starting with v4.0 support for the OLD format may be reported as an error." I forgot I wrote that. We should probably do that soon. (Note to self: Also add a warning when the 2nd parameter is "-").

Bottom line: I'm fine with the types-dnscontrol.d.ts file only showing the modern style.

@andrewimeson
Copy link
Contributor Author

@tlimoncelli I think that makes a lot of sense. The type hints should be best-effort at supporting deprecated-but-not-yet-removed syntax.

Prior to this it would only work if you did the deprecated style of
passing the provider type first.

```js
NewDnsProvider("bind", "BIND" {"stuff": "stuff"})
```

But it wouldn't support omitting the optional provider type and
specifying the extra object.

```js
NewDnsProvider("bind", {"stuff": "stuff"})
```

Now the old style is forbidden (in the type hints) to discourage use of
it, although dnscontrol does still allow it.

Fixes StackExchange#3946
Originally fixed this in 6edfbf5, but I fixed it in the generated file
and not the source file. There should probably be a CI check to run the
generate and fail if it has any changes.
Copy link
Collaborator

@tlimoncelli tlimoncelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Could you add a section to documentation/language-reference/top-level-functions/NewDnsProvider.md called # Backwards Compatibility that explains that if you see NewDnsProvider("foo" ,"-" or NewDnsProvider("foo", "PROVIDERNAME this is older syntax that is going away soon. "preview" will print warnings telling you what to change.

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.

TypeScript definitions unhappy with BIND options

3 participants