Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export Node in a way that allows runtime use #540

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

jstasiak
Copy link
Contributor

Previously it wasn't possible to have code like

import { Node } from '@markdoc/markdoc'

function f(): Node {
    // error below: 'Node' cannot be used as a value because it was exported using 'export type'.ts(1362)
    return new Node('tag', {}, [], 'foo')
}

This patch rectifies that and we can have the same type used in return type position and the class instantiation position.

Resolves: #539

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Previously it wasn't possible to have code like

    import { Node } from '@markdoc/markdoc'

    function f(): Node {
        // error below: 'Node' cannot be used as a value because it was exported using 'export type'.ts(1362)
        return new Node('tag', {}, [], 'foo')
    }

This patch rectifies that and we can have the same type used in return
type position and the class instantiation position.

Resolves: markdoc#539
@@ -113,6 +114,7 @@ export {
transforms,
renderers,
Ast,
Node,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was afraid

export * from './src/types';

was going to clash with this (re)export but after some preliminary tests I think it's fine.

@matv-stripe matv-stripe merged commit 2e2d2c4 into markdoc:main Jan 24, 2025
2 checks passed
@jstasiak jstasiak deleted the export-full-node branch January 27, 2025 08:33
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.

type-only exports make some code somewhat inconvenient
3 participants