我正在尝试声明要从 TypeScript 导入的特定 SCSS 模块。我有这个运行良好的声明文件:
declare module '*.scss' {
const styles: {
a: string
b: string
c: string
}
export default styles
}
但我想缩小 *.scss
不知何故,这个声明文件只适用于 SCSS 文件 _variables.scss
它位于同一目录中。我试图替换
*.scss
与 _variables.scss
或 ./_variables.scss
但后来 TypeScript 根本找不到模块声明。TypeScript 可以做到这一点吗?
最佳答案
您可以像这样进行模块声明。阅读更多关于通配符模块声明 here .
declare module '*_variables.scss' {
const styles: {
a: string
b: string
c: string
}
export default styles
}
关于TypeScript 声明特定的 SCSS 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64198691/