BinaryMuse / toml-node

TOML parser for Node.js and the Browser. Parses TOML v0.4.0
http://binarymuse.github.io/toml-node/
MIT License
306 stars 30 forks source link

✨ Improve type definition of `parse` function #62

Closed micalevisk closed 1 year ago

micalevisk commented 2 years ago

Now users can optionally supply the type of the parsed data like the following:

const myData = toml.parse<MyData>(myInput);
//        ^? MyData

instead of doing

const myData: MyData = toml.parse(myInput);

Notice that the default type is still any thus both approach above works.


As an workaround to this, I augmented toml with this ambient file:

toml.d.ts ```ts declare module 'toml' { export function parse(input: string): TOutput; } ```
micalevisk commented 2 years ago

Hi @BinaryMuse! can you please review this one? it should be pretty straightforward :smiley:

micalevisk commented 1 year ago

I fond that this is a bad style. We should return unknown instead