Skip to content

import yaml as const #4

@FlorianB-DE

Description

@FlorianB-DE

Hey there,
for my use case it would be nice, if the yaml could be imported "as const" so that typescript would make literal types e.g.

test:
  one: one
  two: two
import test from "./test.yaml";
// currently: 
typeof test // -> { test: { one: string, two: string } }

// as const
typeof test // -> { test: { one: "one", two: "two" } }

this would be beneficial to mapped types since we can then narrow the inference:

type Keys = keyof typeof test['test']; // is "one" | "two"
type Values = typeof test['test'][Keys]; // is string but could be "one" | "two" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions