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

added types #12

Merged
merged 1 commit into from
Oct 12, 2020
Merged

added types #12

merged 1 commit into from
Oct 12, 2020

Conversation

DerMolly
Copy link
Contributor

As part of HedgeDoc we wrote these type definitions to use the plugin, but we think they would have a far better home in this repository.

@parksb
Copy link
Owner

parksb commented Oct 12, 2020

Thank you!

@parksb parksb merged commit c8178ed into parksb:master Oct 12, 2020
@OpportunityLiu
Copy link
Contributor

Doesn't work here. What options of typescript you are using? @DerMolly

ERROR in node_modules/markdown-it-front-matter/index.d.ts:5:3 - error TS2309: An export assignment cannot be used in a module with other exported elements.

5   export = markdownItFrontMatter
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error Command failed with exit code 1.

@DerMolly
Copy link
Contributor Author

DerMolly commented Oct 12, 2020

@OpportunityLiu

Our tsconfig:

https://github.com/codimd/react-client/blob/main/tsconfig.json

Our usage;

https://github.com/codimd/react-client/blob/main/src/components/markdown-renderer/markdown-it-plugins/frontmatter.ts

I just tried it again and removed the types in our repo and installed the types from this repo via a local folder and it works. It could be that "allowSyntheticDefaultImports": true, in our tsconfig is makeing it work. In this case could you try changing export = markdownItFrontMatter to export default markdownItFrontMatter and tell me if that worked better?

@DerMolly DerMolly deleted the types branch October 12, 2020 07:35
@OpportunityLiu
Copy link
Contributor

export default makes require('markdown-it-front-matter').default to be the exported plugin, which is incorrect.

This might be better

declare module 'markdown-it-front-matter' {
  import MarkdownIt from 'markdown-it/lib'

  namespace markdownItFrontMatter {
    type FrontMatterPluginOptions = (rawMeta: string) => void
  }
  const markdownItFrontMatter: MarkdownIt.PluginWithOptions<markdownItFrontMatter.FrontMatterPluginOptions>
  export = markdownItFrontMatter
}

@DerMolly
Copy link
Contributor Author

Would you like to open a PR with this change?

@OpportunityLiu OpportunityLiu mentioned this pull request Oct 12, 2020
DerMolly added a commit to hedgedoc/react-client that referenced this pull request Jan 14, 2021
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.

3 participants