seek-oss / css-modules-typescript-loader

Webpack loader to create TypeScript declarations for CSS Modules
MIT License
198 stars 27 forks source link

feat: add compile-time checking for selectors that don't exist when using index signature syntax, ie. a['my-selector'] #26 #29

Closed silbinarywolf closed 5 years ago

silbinarywolf commented 5 years ago

feat: add compile-time checking for selectors that don't exist when using index signature syntax, ie. a['my-selector']

silbinarywolf commented 5 years ago

@mattsjones Mind giving this a review? I'm not sure how to get robust tests on this logic without having TypeScript as a dep and actually running it through the type-checker :/

mattcompiles commented 5 years ago

TypeScript doesn't seem to like this. Here's a playground link that throws an error for this definition.

http://www.typescriptlang.org/play/?ssl=2&ssc=1&pln=3&pc=1#code/JYOwLgpgTgZghgYwgAgMIGd0FEAeAHAeyjHWQG8AoZZAbQGsIBPALmXTClAHMBdVgNwLAAJgG5kVZAHIiAIymt2nEF1EUAvhQoICIdsjisM2fERLIAvOUnU5rKVI1qgA

silbinarywolf commented 5 years ago

Huh that's interesting. Cheers.

We're running that exact version right now and I didn't see such an error come up when I manually tested this with *.d.ts files. I tweaked the playground to closer match what we do but it still gets errors.

This signals to me that merging this in would be a bad idea, though I don't understand why it's working with our build system. (Not that crazy, Webpack + ts-loader + TypeScript outputting ES5)

I'll close this for the time-being until I figure out a better solution.