title: Typescript convert string in json to string literal
body: <p>I have a json config file checked into my project that looks something like this:</p>
  
  <pre><code>{
    "flag": "one"
  }
  </code></pre>
  
  <p>and I want to check the type of this json file, with a type that includes string literals.</p>
  
  <pre><code>import someconfig from './configs/someconfig.json'
  type Config = {
    flag: 'one' | 'two'
  }
  
  
  const config: Config = someconfig
  </code></pre>
  
  <p>which results in this error:</p>
  
  <pre><code>error TS2322: Type '{ "flag": string; }' is not assignable to type 'Config'.
    Types of property 'flag' are incompatible.
      Type 'string' is not assignable to type '"one" | "two"'.
  
   const config: Conf = someconfig
          ~~~~~~
  </code></pre>
  
  <p>This means I cannot check the types of any json files against a type that uses literals. This is explained as widening types in this <a href="https://github.com/Microsoft/TypeScript/issues/27913" rel="nofollow noreferrer">typescript issue</a>. Still, I want to know if I can convert strings to string literals somehow. I have found an example <a href="https://basarat.gitbooks.io/typescript/docs/types/literal-types.html" rel="nofollow noreferrer">https://basarat.gitbooks.io/typescript/docs/types/literal-types.html</a> which sort-of widens types from strings to string literals. Is it possible to accomplish this from a json file?</p>
  
  <p>my tsconfig.json file:</p>
  
  <pre><code>{
    "compilerOptions": {
      "outDir": "./lib/",
      "sourceMap": true,
      "noImplicitAny": true,
      "strictNullChecks": true,
      "lib": ["es2015", "es2016", "es2017"],
      "module": "commonjs",
      "moduleResolution": "node",
      "target": "es2017",
      "allowJs": true,
      "esModuleInterop": true,
      "resolveJsonModule": true,
      "allowSyntheticDefaultImports": true
    },
    "include": [
      "src/**/*.ts",
      "examples/**/*.ts",
      "custom.d.ts",
      "testing/**/*.ts"
    ]
  }
  </code></pre>