Skip to content

Update all remaining code blocks to have TS/JS toggles #1203

New issue

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

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

Already on GitHub? # to your account

Open
markerikson opened this issue Jun 22, 2021 · 10 comments
Open

Update all remaining code blocks to have TS/JS toggles #1203

markerikson opened this issue Jun 22, 2021 · 10 comments
Labels

Comments

@markerikson
Copy link
Collaborator

We have a number of code blocks that are still JS-only. It would be useful to convert all of them to be toggleable TS/JS blocks instead. As an example, the initial example in createAsyncThunk:

https://redux-toolkit.js.org/api/createAsyncThunk#overview

@PrinceRajRoy
Copy link
Contributor

Hi Mark, is this supposed to be done using the same remark tool?

@phryneas
Copy link
Member

phryneas commented Jun 22, 2021

In the long run we might switch to shiki-twoslash once they add a feature like that, but for now yes.

Generally: rename file to .mdx, fix up the TypeScript to successfully compile.

@PrinceRajRoy
Copy link
Contributor

@phryneas great! just a quick query, the website dir contains package-lock.json but the README directs to use yarn instead, is that intended?

@phryneas
Copy link
Member

I assume that is the default docusaurus README, just ignore it for now. We will switch over to a yarn monorepo soon anyways.

@phryneas
Copy link
Member

Also, you might run into memory problems on the main branch. Update remark-typescript-tools to 1.0.7 to fix that.

@PrinceRajRoy
Copy link
Contributor

@phryneas I'm trying to use the remark-typescript-tools on jsx snippets, but it doesn't seem to work. I have updated it to v1.0.7 before using, so I'm a bit confused here. Sorry if I'm missing something here 😅

Snippet

// file: App.tsx noEmit
import React from 'react'
export default function App() {
  return <div>...</div>
}

// file: app/store.ts noEmit
import { configureStore } from '@reduxjs/toolkit'

export default configureStore({
  reducer: {},
})

// file: index.tsx
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
// highlight-start
import store from './app/store'
import { Provider } from 'react-redux'
// highlight-end

ReactDOM.render(
  // highlight-next-line
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
)

Works fine with "jsx": "react"

1

Doesn't work with "jsx": "preserve"

2

@phryneas
Copy link
Member

Uhh, good question. I think we never had this use case before 😅 I might need to investigate that. But probably not before friday.

@phryneas
Copy link
Member

@PrinceRajRoy I just pushed remark-typescript-tools 1.0.8 which should be able to handle jsx: 'preserve'

@PrinceRajRoy
Copy link
Contributor

@phryneas just updated, works perfectly fine now 😄

@akashshyamdev
Copy link
Contributor

akashshyamdev commented Sep 26, 2021

@phryneas @markerikson the createAsyncThunk overview doesn't have the toggle. Can I handle that?

Screenshot 2021-09-26 at 10 22 30

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants