New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding a warnings for incorrect tagged template literal usage in development #352
Comments
I would suggest to check it slightly different way. Something like. if (process.env.NODE_ENV !== 'production' && !(Array.isArray(strings))) {
console.error('...')
} To clarify: injectGlobal`html { color: red; }`
// works the same way as
injectGlobal([ `html { color: red; }` ])
// (If there is no interpolations!!!) On the other hand, we could support incorrect usage? injectGlobal(`html { color: red; }`)
// will be equivalent to
injectGlobal([ `html { color: red; }`])
// or
injectGlobal`html { color: red; }` |
This seems reasonable. Whatever we can do to avoid people adding bugs to their apps 👍 |
I'll take this one. Just to clarify, we want to allow incorrect usage or show error when incorrectly used? |
Introducing an error now would be a breaking change, so let's just log a warning? |
Is it still open? |
@maksugr Could you make a PR for your completed commits? |
@chengjianhua it is right here |
@maksugr 🤣 So this issue can be closed now? |
Yup |
I was adding styled-components to an app and global styles weren't showing up. There weren't any errors and it wasn't immediately obvious what I was doing wrong. It turned out I was using
injectGlobal
wrong:The first argument of tagged template literals includes a
raw
property. Adding a check in development to prints out an error whenstrings.raw
is missing would help catch this kind of mistake. I'm not sure how frequently this happens, but considering the relative rarity of tagged template literal usage, I figure it wouldn't hurt.The text was updated successfully, but these errors were encountered: