styled-components / vscode-styled-components

Syntax highlighting for styled-components
MIT License
917 stars 117 forks source link

'identifier expected' error when using a string template followed by a pseudo-element selector #440

Open Codex- opened 9 months ago

Codex- commented 9 months ago

Describe the bug (including copyable syntax)

When writing a styled component with a string template, if you use a template for the identifier (a) followed by a pseudo selector (:after) it results in an error .${a}:after {

Screenshot
Screenshots are alway useful! image

To Reproduce

const test = ''
const StyledDiv = styled.div`
  .${test}:before { // <- identifier expected (ts-styled-plugin(9999))
    border-bottom: none;
    transition: none;
  }
`

Expected behavior
No error as this is a valid identifier

Build environment (please complete the following information):

Extensions

code --list-extensions DavidAnson.vscode-markdownlint dbaeumer.vscode-eslint eamodio.gitlens EditorConfig.EditorConfig esbenp.prettier-vscode firsttris.vscode-jest-runner github.vscode-github-actions GitHub.vscode-pull-request-github ms-azuretools.vscode-docker ms-python.python ms-python.vscode-pylance ms-vscode-remote.remote-containers ms-vscode-remote.remote-ssh ms-vscode-remote.remote-ssh-edit ms-vscode.cmake-tools ms-vscode.cpptools ms-vscode.cpptools-extension-pack ms-vscode.cpptools-themes ms-vscode.live-server ms-vscode.remote-explorer PKief.material-icon-theme redhat.java rust-lang.rust-analyzer ryanluker.vscode-coverage-gutters SonarSource.sonarlint-vscode streetsidesoftware.code-spell-checker styled-components.vscode-styled-components tamasfe.even-better-toml twxs.cmake VisualStudioExptTeam.intellicode-api-usage-examples VisualStudioExptTeam.vscodeintellicode vscjava.vscode-java-debug vscjava.vscode-java-dependency vscjava.vscode-java-pack vscjava.vscode-java-test vscjava.vscode-maven yoavbls.pretty-ts-errors ZixuanChen.vitest-explorer

Additional context