'Cannot find module './styles.scss' or its corresponding type declarations
i install
yarn create react-app my-app --template typescript
yarn add sass
App.tsx
import styles from "./styles.scss";
function App() {
return <div className={styles.App}></div>;
}
export default App;
styles.scss
.App {
text-align: center;
}
both files in the same folder
when i want to import, i get this error
Cannot find module './styles.scss' or its corresponding type declarations
Solution 1:[1]
this problem is because you install typescript on existed react-app.
first put a "declarations.d.ts" in your project and add the following line-code to it:
declare module '*.css';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | danial |