Open pmyagkov opened 7 years ago
@Quramy could you comment this please?
@pmyagkov I'm attempting to reproduce your error TS7017
, but I can't...
/* a.ts */
import * as cn from 'classnames';
import * as styles from "./styles.css";
type Theme = 'dark' | 'light';
// type Theme = keyof typeof styles; // It works too.
const theme: Theme = 'dark';
const className = cn(styles.dark, {
[styles[theme]]: true,
});
/* styles.css.d.ts [generated by tcm] */
export const dark: string;
export const light: string;
And my tsconfig.json is :
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true
}
}
There is no compilation error. Would you tell me a reproducing repository?
I'll provide a minimal reproducible demo in a mean time.
I have same problem.
Issue
Right now it's impossible to get a
styles
value using an indexer:The first snippet doesn't work because of an error:
Possible resolution
To generate kind of extended styles typings: