简体   繁体   English

找不到模块“module.css”或其相应的类型声明

[英]Cannot find module 'module.css' or its corresponding type declarations

Don't know why typescript suddenly not recogize my code, it show不知道为什么 typescript 突然不识别我的代码,它显示

Cannot find module './hookStyle/useMemostyle.module.css' or its corresponding type declarations

It happen when i move style to another folder当我将样式移动到另一个文件夹时发生

Here is typescript config这是 typescript 配置

{
  "compilerOptions": {
    "lib": [
      "ESNext",
      "dom"
    ],
    "outDir": "lib",
    "removeComments": true,
    "target": "ES6",
    "baseUrl": "src",
    "esModuleInterop": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "sourceRoot": "/",
    "alwaysStrict": true,
    "allowUnreachableCode": false,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitReturns": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "allowJs": true,
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "./**/*.ts"
  ],
  "exclude": [
    "node_modules/**/*"
  ]
}

It not effect the code, it still working but why typescript show that error?它不影响代码,它仍然有效,但为什么 typescript 显示该错误? How can i fix it?我该如何解决?

To import custom file types, you must use TypeScript's declare module syntax to let it know that it's ok to import.要导入自定义文件类型,您必须使用TypeScript 的declare module语法让它知道可以导入。 To do this, simply create a globals.d.ts (declaration file) wherever your other code's root directory is and then add in this code:为此,只需在其他代码的根目录所在的位置创建一个globals.d.ts (声明文件),然后添加以下代码:

declare module '*.css';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到模块“react-lazily”或其相应的类型声明 - Cannot find module 'react-lazily' or its corresponding type declarations codesandbox - 找不到模块 PACKAGE 或其相应的类型声明 - codesandbox - Cannot find module PACKAGE or its corresponding type declarations 找不到模块“graphql-hooks”或其相应的类型声明 - Cannot find module 'graphql-hooks' or its corresponding type declarations 找不到模块“./App.svelte”或其对应的类型声明 - Cannot find module './App.svelte' or its corresponding type declarations 如何解决找不到找不到模块'../home/featuredRooms'或其对应的类型声明。? - how to solve cannot find Cannot find module '../home/featuredRooms' or its corresponding type declarations.? React,Storybook - TS2307:找不到模块“按钮”或其相应的类型声明 CAN SB RESOLVE? - React,Storybook - TS2307: Cannot find module 'Button' or its corresponding type declarations CAN SB RESOLVE? 找不到模块“@react-navigation/native”或其相应的类型声明 - Cannot find module '@react-navigation/native' or its corresponding type declarations Docker/Next js:: 找不到模块“@mui/x-date-pickers/AdapterDateFns”或其相应的类型声明 - Docker/Next js :: Cannot find module '@mui/x-date-pickers/AdapterDateFns' or its corresponding type declarations 为什么我收到此错误找不到模块“nestjs/common”或其相应的类型声明 - Why I got this error Cannot find module 'nestjs/common' or its corresponding type declarations vite-plugin-pages 出错找不到模块'~pages'或其相应的类型声明 - vite-plugin-pages got error Cannot find module '~pages' or its corresponding type declarations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM