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
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';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.