I have the following yaml
file:
trainingPhrases:
- help me
- what to do
- how to play
- help
I readi it from disk using readFile
from node and parse it using load
from js-yaml
:
import { load } from "js-yaml";
import { readFile } from "fs/promises";
const phrases = load(await readFile(filepath, "utf8")).trainingPhrases as string[];
I get the following eslint
warning:
ESLint: Unsafe member access .trainingPhrases on an any value.(@typescript-eslint/no-unsafe-member-access)
Instead of suppressing the warning, I would like to map it into a concrete type for the YAML file (as it happens in axios for example: axios.get<MyResponseInterface>(...)
- performs a GET
and MyResponseInterface
defines the structure of the HTTP response).
Is there a dedicated library for that?