steveukx / properties

Properties reader for Node.js
MIT License
77 stars 33 forks source link

import syntax not working #38

Open penguinsAreFunny opened 3 years ago

penguinsAreFunny commented 3 years ago

Hello,

I am not sure if I am mistaken, but I have no import-syntax working for properties-reader (using TypeScript). Documentation: const propertiesReader = require("properties-reader"); // works fine const properties = propertiesReader("path");

Trying to use modern import-syntax does not work for me. import * as propertiesReader from "properties-reader"); // does not work import {PropertiesReader} from "properties-reader"; // does not work import {propertiesReader} from "properties-reader"; // does not work import {PropertiesReader} from "properties-reader/src/properties-reader"; // does not work [...]

This might not be an issue but just me not understanding why this is not working. I have looked up require to import converters, which would convert the require-statement into one of the import statements above. I think it is not working because of the unusual directory-structure of npm-properties-reader. Usually an npm module has an index.js file directly in the directory folder exporting all other visible modules.

I think it would be great if properties-reader import-syntax would be fair to conventions.

steveukx commented 3 years ago

Hi, at the moment this library isn't bundled with typescript types, but there are types available on npm as @types/properties-reader which are up to date with the current state of the library.

To import the library you would need to use the default import, eg:

import propertiesReader, { AppenderOptions, ... any other types here ... } from 'properties-reader'`;
penguinsAreFunny commented 3 years ago

Thank you veryr much :)