Replies: 2 comments
-
As documentation outlined, you can define a declare module "*.toml" {
const value: any;
export default value;
} However, the imported type remains |
Beta Was this translation helpful? Give feedback.
0 replies
-
I don't see anything about that in the docs you linked (I looked through all the docs before posting here of course). That works but only if you have just one config file. Here's a more complex example I tested: declare module '*.toml' {
interface Owner {
name: string;
dob: string;
}
interface Database {
enabled: boolean;
ports: number[];
data: (string | number)[][];
temp_targets: {
cpu: number;
case: number;
};
}
interface Server {
ip: string;
role: string;
}
interface Servers {
alpha: Server;
beta: Server;
}
interface TomlExample {
title: string;
owner: Owner;
database: Database;
servers: Servers;
}
const value: TomlExample;
export default value;
} title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = "1979-05-27T07:32:00-08:00"
[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
[servers.beta]
ip = "10.0.0.2"
role = "backend" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Given the following:
Typescript says
Cannot find module 'bun-test-config.toml' or its corresponding type declarations.ts(2307)
The only workaround I can think of is this:
Is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions