asyncapi / asyncapi/parser-js

Binding interface does not support excess properties

Open Beginner friendly
#735 12 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
144
Forks
144
Avg merge
6m
Merged PRs (30d)
11

Description

#### Describe the bug
The OldServer, ServerV2, and Server classes do not support excess properties on the Binding interface.

#### How to Reproduce

using "@asyncapi/parser": "^2.0.0-next-major.15"

```ts
import { OldAsyncAPIDocument, OldServer } from '@asyncapi/parser'

//inside an exported class
private _AsyncAPIServer: OldServer

get AsyncAPIServer(): OldServer {
return this._AsyncAPIServer
}

//in another file with a class that extends the class above

const mqttServerBinding = this.AsyncAPIServer.binding('mqtt')
const mqtt5ServerBinding = this.AsyncAPIServer.binding('mqtt5')

const serverBinding = protocolVersion === 5 ? mqtt5ServerBinding : mqttServerBinding

mqtt.connect({
...
clientId: serverBinding?.clientId ?? auth?.clientId,
clean: serverBinding?.cleanSession,
...
})
```

An error is thrown that `clientId` does not exist on type `Binding`.

![glee_error](https://user-images.githubusercontent.com/61796959/227504358-cc325f08-9ada-4245-9cba-070c0cdb2dfa.png)

The Binding interface
![glee_binding](https://user-images.githubusercontent.com/61796959/227504566-920688a6-d674-490a-8c54-b578e5930a2b.png)

#### Expected behavior
The Binding interface should support excess properties possibly by using `[propName: string]: any;`

Contributor guide

Open the contributing guide

Research direction

Start by locating the Binding interface and the OldServer, ServerV2, and Server binding() entry points in @asyncapi/parser. Check how mqtt and mqtt5 bindings are typed, then verify that clientId and cleanSession are accepted on the returned bindings without breaking existing type checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.