emotion: TS Styled Plugin doesn't recognize the label property as legitimate
emotionversion: 9.2.12reactversion: 16.6
Relevant code. In a typescript .tsx file
const Box = styled("div")`
label: switch-row;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 0 15px;
`
It compiles well and works well. But Visual Studio Code complains. There is a green line under label with the following message: “[ts-styled-plugin] Unknown property: ‘label’”

About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (1 by maintainers)
In case it is useful for anyone else googling their way through this and other closed issues, there is now a way to get ts-styled-plugin to accept the
labelproperty:in
tsconfig.json:Discovered in https://github.com/Microsoft/typescript-styled-plugin/issues/58#issuecomment-444733368
I think I figured it out:
Inside the tsconfig.json instead of:
Try to use
For me, it worked this way!
@hatton you’re right, according to the plugin’s README,
validPropertiestakes an array.However this still didn’t fix it for us, probably because our project doesn’t use Typescript (yet 😛).
I found the fix, at least for VS Code. Instead of a
tsconfig.jsonfile, I added ajsconfig.jsonat the root of the project:After restarting VS Code (to trigger a new linting), the warning disappeared.
I found I had to give it an array:
"validProperties": ["label"](and then reload my vscode window).
@robinmetral
tsconfig.jsonis a configuration file for the TypeScript runtime/compiler. If you are not using TypeScript, this file will obviously have no effect in your runtime.@dylancagnotti wow… I finally resolve this. Thanks!
@robinmetral my apologies. I didn’t know that the plugin also worked for JS files — thought it was TypeScript only.
@Rocamonde in this case
tsconfig.jsonhas nothing to do with compiling. We’re just using it to pass custom linting rules to thets-styled-plugindependency of Emotion.And as explained here:
So
tsconfig.jsonfor JS projects obviously doesn’t compile the code, but it does have an effect on linting, which is what this issue is about.