Skip to content

Relative paths using typescript paths options not being resolved #25

Closed
@bsunderhus

Description

@bsunderhus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions