asyncapi/bundler

Migrate bundler's codebase to TypeScript

aeworxet opened this issue · 10 comments

@Souvikns states in PR
#46
I also think this would be the right time to move to typescript

I would like to take on this issue also.
@derberg @magicmatatjahu @jonaslagoni, there's a need to decide who of us two will migrate the bundler's codebase to TypeScript.

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Awesome! As I know you @aeworxet wanna to do it, so for me you can start from now, but let's wait for @Souvikns opinion whether he would like to do it with you in coop.

It would be awesome if PR
#46
is merged, so the code is more up-to-date and ready for immediate action.

I am not a code owner, so it's not my review that's blocking it 😄 ⬆️ cc @derberg

@Souvikns opinion whether he would like to do it with you in coop.

Yeah @aeworxet you can take on the issue, I can help you with anything you need.

@aeworxet thanks for volunteering 🙇🏼

During assignment of TS types to functions' parameters and variables I have run into type errors in parser.ts which can be solved only by maintainers:

$ tsc

src/parser.ts:37:75 - error TS2559: Type '$Refs' has no properties in common with type 'JSONSchema7'.
37             const componentObject = await resolveExternalRefs(JSONSchema, $ref);
                                                                             ~~~~

src/parser.ts:38:28 - error TS2339: Property 'components' does not exist on type 'JSONSchema7'.
38             if (JSONSchema.components) {
                              ~~~~~~~~~~

src/parser.ts:39:34 - error TS2339: Property 'components' does not exist on type 'JSONSchema7'.
39                 merge(JSONSchema.components, componentObject);
                                    ~~~~~~~~~~

src/parser.ts:41:28 - error TS2339: Property 'components' does not exist on type 'JSONSchema7'.
41                 JSONSchema.components = componentObject
                              ~~~~~~~~~~

src/parser.ts:68:98 - error TS7031: Binding element 'parent' implicitly has an 'any' type.
68     JSONPath({ json: parsedJSON, resultType: 'all', path: '$.channels.*.*.message' }).forEach(
  ({ parent, parentProperty }) => {
     ~~~~~~

src/parser.ts:68:106 - error TS7031: Binding element 'parentProperty' implicitly has an 'any' type.
68     JSONPath({ json: parsedJSON, resultType: 'all', path: '$.channels.*.*.message' }).forEach(
  ({ parent, parentProperty }) => {
             ~~~~~~~~~~~~~~

src/parser.ts:71:33 - error TS2339: Property 'get' does not exist on type 'JSONSchema7'.
71             const value = $refs.get(ref);
                                   ~~~

src/parser.ts:73:13 - error TS7053: Element implicitly has an 'any' type because expression of
type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.
73             componentObj.messages[String(component.getKey())] = component.getValue()
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 8 errors in the same file, starting at: src/parser.ts:37

@Souvikns @magicmatatjahu @derberg

@aeworxet can you open a PR with your current code, I will take a look.