openapi-typescript version
7.9.1
Node.js version
24.5.0
OS + version
NixOS 25.11
Description
I'm trying to load a request body from a json file. When I do that i get type errors on the assignment to a variable that is annotated with the corresponding type. If I manually construct the json inline typescript is totally happy. The error I get is Type 'string' is not assignable to type '"bar"'. I can try to provide more information if it will help. But I can't share my actual types/api so it will require a little bit of work.
<script lang="ts">
import type { components } from "./mySchema";
// Typescript is happy here
let x: components['schema']['MyType'] = { foo: "bar" }
// Typescript gives me type errors here
import data from './example.json';
let x: components['schema']['MyType'] = data
</script>
example.json:
Reproduction
If needed I can try to make a minimal reproduction. But I first wanted to hear if this is expected/trivial to solve.
Expected result
Expecting no type errors
Required
Extra
openapi-typescript version
7.9.1
Node.js version
24.5.0
OS + version
NixOS 25.11
Description
I'm trying to load a request body from a json file. When I do that i get type errors on the assignment to a variable that is annotated with the corresponding type. If I manually construct the json inline typescript is totally happy. The error I get is
Type 'string' is not assignable to type '"bar"'. I can try to provide more information if it will help. But I can't share my actual types/api so it will require a little bit of work.example.json:{ "foo": "bar" }Reproduction
If needed I can try to make a minimal reproduction. But I first wanted to hear if this is expected/trivial to solve.
Expected result
Expecting no type errors
Required
npx @redocly/cli@latest lint)Extra