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.
It would be awesome if PR
#46
is merged, so the code is more up-to-date and ready for immediate action.
⬆️ cc @jonaslagoni
I am not a code owner, so it's not my review that's blocking it 😄 ⬆️ cc @derberg
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