React Material UI extremely slows VSCode autocompletion with TS

Viewed 1020

Importing the "@mui/material" will stuck the VSCode - so TS warnings will come up after 10-15s instead of less than 10ms, for example:

import { Button } from '@mui/material'
// and make a use with this button.

Then:

new Date(). // will show the autocomplion very slow

If you remove the import of that button, or any module from this package, everything works great again.

1 Answers

To import components, use path imports instead of top-level imports:

// ❌ top-level imports
// import { Box, Typography } from '@mui/material'

// ✅ path imports
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'

This will speed up Typescript autocompletion.

Related