Closed
Description
Apparently, the plugin is not able to resolve the types for files that are relative to some path declaration on the typescript configuration.
My tsconfig.json
:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~": ["./src/index.tsx"],
"~/*": ["./src/*"]
},
"sourceMap": true,
"target": "esnext",
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"isolatedModules": false,
"esModuleInterop": true,
"declaration": false,
"resolveJsonModule": true,
"experimentalDecorators": true,
"lib": [
"dom",
"esnext"
],
"plugins": [
{
"name": "typescript-styled-plugin",
"tags": [
"css"
]
},
{
"name": "typescript-plugin-css-modules",
"options": {
"customMatcher": "\\.(sc|c)ss$",
"camelCase": "only"
}
}
],
"typeRoots": [
"./node_modules/@types",
"./@types"
]
},
"include": [
"src",
"webpack"
]
}
In my TS file if I import a style by an absolute path, everything works fine, but if the file path is relative to the ~
it simply doesn't work
import globalStyle from '~/styles/style.scss' // Doesn't work at all
import globalStyle2 from '../../styles/style.scss' // Works just fine
- OS: OSX 10.14.5
- Browser: Chrome
- Version: 75