I am new to TypeScript and I don't understand what I need to do to fix the line that generates the TS7015 error (referencing an enum member using a string variable) because the line immediately following that does not error (referencing an enum member using a string literal):
enum State {
    Happy = 0,
    Sad = 1,
    Drunk = 2
}
function Emote(enumKey:string) {
    console.log(State[enumKey]); // error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
    console.log(State["Happy"]); // no error
}
"noImplicitAny": true is set in the project's tsconfig.json the error is detected
"noImplictAny": false is set in the project's tsconfig.json no error is detected
I'm compiling with "ntypescript": "^1.201603060104.1"
I'm now compiling with "tsc": "1.8.10"
C:>npm install -g typescript
`-- [email protected]
Verifying installation:
C:\>tsc --version
Version 1.8.10
Here's my tsconfig.json file:
{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "ES5",
    "module": "System",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": true,
    "sourceMap": true,
    "mapRoot": "map/",
    "diagnostics": true
  },
  "exclude": [
    "node_modules",
    "typings"
  ]
}
Here's the compiler output:
C:\>tsc
test.ts(8,17): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.




noImplicitAnytofalsemakes the error go away...ntypescriptlooks like it's mostly for people who want to work directly with the TypeScript compiler API. I think you wanttypescript...