Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

TypeScript doesn't type-check MDX #113

Open
plusk opened this issue Oct 23, 2019 · 7 comments
Open

TypeScript doesn't type-check MDX #113

plusk opened this issue Oct 23, 2019 · 7 comments
Labels
Bug Something that just ain't right Priority: High

Comments

@plusk
Copy link
Member

plusk commented Oct 23, 2019

This leads to errors all the time with people using for example disabled="false", which would evaluate to disabled because the string "false" is a truthy value.
If TypeScript looks over the .mdx files and makes sure the proper types are used, we avoid this.

@plusk plusk added Bug Something that just ain't right Priority: Medium Priority: High and removed Priority: Medium labels Oct 23, 2019
@FluidSense
Copy link
Contributor

mdx-js/mdx#255
Prettier seemingly supports mdx, perhaps that's something we can check out.
https://github.com/rx-ts/eslint-mdx
Or this^

@JounQin
Copy link

JounQin commented Nov 17, 2019

@plusk
eslint-mdx has been enabled in the project, is there anything unexpected?

@FluidSense
Copy link
Contributor

@JounQin
The error might be related to any of storybook, eslint and typescript.
Currently, we write our project in TypeScript and have defined types on props.
Given this component:

interface Example {
  input: string,
}

const SomeComponent = ({ input }: Example) => { ... }
export default SomeComponent;

and the mdx-story containing this jsx

<Preview>
  <Story>
     <SomeComponent input={false} />
  </Story>
</Preview>

We would like for this faulty input type to be noticed.
Currently, the code above will be accepted by Storybook, it will be accepted by TypeScript (as it does not check .mdx-files) and it will be accepted by eslint.
Added eslint-mdx to our project, but the example above is still accepted.

@JounQin
Copy link

JounQin commented Nov 23, 2019

Please provide a minimal runnable reproduction, otherwise I can't offer any help.

@FluidSense
Copy link
Contributor

Thanks @JounQin! I'll try to set up a minimal runnable reproduction tomorrow.

@FluidSense
Copy link
Contributor

@JounQin
I created this minimal project https://github.com/FluidSense/mdx-cra-ts-loader
and eslint-mdx works as intended.
I will reword our issue as it is TypeScript which is not type-checking MDX. I see this is an issue at another framework as well.
MDX bypasses type-checking as it is compiled to jsx, not tsx.
Exactly how to address this in our project is still an issue, but it is not related to eslint.

@FluidSense FluidSense changed the title Eslint doesn't check MDX TypeScript doesn't type-check MDX Nov 24, 2019
@JounQin
Copy link

JounQin commented Nov 24, 2019

Then a custom TypeScript transformer plugin is required AFAIK.
And that's the worth for using eslint-mdx here, LOL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something that just ain't right Priority: High
Projects
None yet
Development

No branches or pull requests

3 participants