Skip to content

TypeScript server is silently dying when having comments and/or commented variables in SCSS files #13

Closed
@ChristianIvicevic

Description

@ChristianIvicevic

Describe the bug
If any SCSS file happens to include comments that somehow have SCSS variables in them, your plugin will throw an exception and silently cripple the TypeScript server which seizes to work. It seems to attempt to parse the variables nonetheless.

To Reproduce
Steps to reproduce the behavior:

  1. Create a CRA2.1 app with node-sass installed

  2. Add a Foo.module.scss file.

  3. Add the following code to it:

     .foo {
         width: 100px;
     }
    
     // .locationPanel {
     //     height: calc(100vh - #{$pt-navbar-height});
     //     width: $locationPanel-width;
     // }
    
     // .locationDetails {
     //     height: calc(100vh - #{$pt-navbar-height});
     //     width: calc(100% - #{$locationPanel-width});
     // }
    
  4. Import it using import styles from "./Foo.module.scss";

  5. Notice how the TypeScript server output will show errors and no more quick infos are usable

Expected behavior
No crash of the TypeScript server.

Screenshots
This is an excerpt of the TypeScript server log which shows the initial exception.

<css input>:14:1: Unknown word

CssSyntaxError: <css input>:14:1: Unknown word
    at Input.error (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/input.js:130:16)
    at Parser.unknownWord (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/parser.js:559:22)
    at Parser.other (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/parser.js:168:12)
    at Parser.parse (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/parser.js:77:16)
    at parse (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/parse.js:17:12)
    at new LazyResult (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/lazy-result.js:60:16)
    at Processor.<anonymous> (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/processor.js:138:12)
    at Processor.process (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/node_modules/postcss/lib/processor.js:117:23)
    at Object.exports.getClasses (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/lib/helpers/cssSnapshots.js:9:47)
    at Object.exports.getDtsSnapshot (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/lib/helpers/cssSnapshots.js:23:27)
    at Object.ts.createLanguageServiceSourceFile (/Users/christian/Projects/graphql-pokemon/node_modules/typescript-plugin-css-modules/lib/index.js:23:49)

Desktop (please complete the following information):

  • OS: macOS 10.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions