Initial code to translate getdocs to TypeScript declaration #3

Closed
RatoX wants to merge 1 commit from initial-translation-to-type-script-declaration into master
RatoX commented 2018-12-12 04:23:30 +01:00 (Migrated from github.com)

Hello @marijnh

I'm working in a proper solution to convert getdocs to TypeScript declaration, and this is the initial work. My main idea is to use the proper TS compiler to generate it for us, but for now I'm doing this manually, I hope you could check and merge this PR then I could improve this much more and add some tests.

getdocs example

// :: (nodeType: union<NodeType, [NodeType]>, type: ?union<NodeType, null>, attrs: ?union<Object, null>, marks?: [Mark]) → (tr: Transaction) → Transaction

ts-declaration expected

export function setParentNodeMarkup(nodeType: NodeType | NodeType[], type?: NodeType, attrs?: Object, marks?: Mark[]) : (tr: Transaction) => Transaction
Hello @marijnh I'm working in a proper solution to convert `getdocs` to TypeScript declaration, and this is the initial work. My main idea is to use the proper TS compiler to generate it for us, but for now I'm doing this manually, I hope you could check and merge this PR then I could improve this much more and add some tests. getdocs example ``` // :: (nodeType: union<NodeType, [NodeType]>, type: ?union<NodeType, null>, attrs: ?union<Object, null>, marks?: [Mark]) → (tr: Transaction) → Transaction ``` ts-declaration expected ``` export function setParentNodeMarkup(nodeType: NodeType | NodeType[], type?: NodeType, attrs?: Object, marks?: Mark[]) : (tr: Transaction) => Transaction ```
marijnh commented 2018-12-12 10:50:15 +01:00 (Migrated from github.com)

This is a neat prototype. But I wonder whether you need to integrate it with builddocs at all—wouldn't it be just as easy to build it as a separate project? What builddocs components are actually necessary to do this?

CC @bradleyayers who I believe has used a similar approach to generate https://www.npmjs.com/package/atlassian-prosemirror-type-definitions . Is that code open somewhere?

This is a neat prototype. But I wonder whether you need to integrate it with builddocs at all—wouldn't it be just as easy to build it as a separate project? What builddocs components are actually necessary to do this? CC @bradleyayers who I believe has used a similar approach to generate https://www.npmjs.com/package/atlassian-prosemirror-type-definitions . Is that code open somewhere?
bradleyayers commented 2018-12-12 22:36:07 +01:00 (Migrated from github.com)

We used https://github.com/bradleyayers/getdocs2ts initially, and it was okay, but eventually switched to manually curating them to because TypeScript can be more expressive than docs (e.g. generic type variables).

@RatoX in your types null should be included when translating ?foo, i.e. ?foo -> foo | null | undefined

We used https://github.com/bradleyayers/getdocs2ts initially, and it was okay, but eventually switched to manually curating them to because TypeScript can be more expressive than docs (e.g. generic type variables). @RatoX in your types `null` should be included when translating `?foo`, i.e. `?foo -> foo | null | undefined`

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
marijn/builddocs!3
No description provided.