Skip to content

Commit

Permalink
remove .d.ts from import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
antonk52 committed Feb 18, 2024
1 parent 7fb11f4 commit 2c68a1a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ function parentDir(p) {
return path.dirname(p) || path.sep;
}

/** @type {import('./index.d.ts').LoaderSync} */
/** @type {import('./index').LoaderSync} */
const jsonLoader = (_, content) => JSON.parse(content);
/** @type {import('./index.d.ts').LoadersSync} */
/** @type {import('./index').LoadersSync} */
const defaultLoadersSync = Object.freeze({
'.js': require,
'.json': require,
Expand All @@ -48,7 +48,7 @@ const defaultLoadersSync = Object.freeze({
});
module.exports.defaultLoadersSync = defaultLoadersSync;

/** @type {import('./index.d.ts').Loader} */
/** @type {import('./index').Loader} */
const dynamicImport = async id => {
try {
const mod = await import(id);
Expand All @@ -74,7 +74,7 @@ const dynamicImport = async id => {
}
};

/** @type {import('./index.d.ts').Loaders} */
/** @type {import('./index').Loaders} */
const defaultLoaders = Object.freeze({
'.js': dynamicImport,
'.mjs': dynamicImport,
Expand All @@ -86,12 +86,12 @@ module.exports.defaultLoaders = defaultLoaders;

/**
* @param {string} name
* @param {import('./index.d.ts').Options | import('./index.d.ts').OptionsSync} options
* @param {import('./index').Options | import('./index').OptionsSync} options
* @param {boolean} sync
* @returns {Required<import('./index.d.ts').Options | import('./index.d.ts').OptionsSync>}
* @returns {Required<import('./index').Options | import('./index').OptionsSync>}
*/
function getOptions(name, options, sync) {
/** @type {Required<import('./index.d.ts').Options>} */
/** @type {Required<import('./index').Options>} */
const conf = {
stopDir: os.homedir(),
searchPlaces: getDefaultSearchPlaces(name, sync),
Expand Down Expand Up @@ -138,7 +138,7 @@ function validateFilePath(filepath) {
if (!filepath) throw new Error('load must pass a non-empty string');
}

/** @type {(loader: import('./index.d.ts').Loader, ext: string) => void} */
/** @type {(loader: import('./index').Loader, ext: string) => void} */
function validateLoader(loader, ext) {
if (!loader) throw new Error(`No loader specified for extension "${ext}"`);
if (typeof loader !== 'function')
Expand All @@ -151,7 +151,7 @@ const makeEmplace = enableCache => (c, filepath, res) => {
return res;
};

/** @type {import('./index.d.ts').lilconfig} */
/** @type {import('./index').lilconfig} */
module.exports.lilconfig = function lilconfig(name, options) {
const {
ignoreEmptySearchPlaces,
Expand All @@ -168,7 +168,7 @@ module.exports.lilconfig = function lilconfig(name, options) {

return {
async search(searchFrom = process.cwd()) {
/** @type {import('./index.d.ts').LilconfigResult} */
/** @type {import('./index').LilconfigResult} */
const result = {
config: null,
filepath: '',
Expand Down Expand Up @@ -264,7 +264,7 @@ module.exports.lilconfig = function lilconfig(name, options) {
}),
);
}
/** @type {import('./index.d.ts').LilconfigResult} */
/** @type {import('./index').LilconfigResult} */
const result = {
config: null,
filepath: absPath,
Expand Down Expand Up @@ -310,7 +310,7 @@ module.exports.lilconfig = function lilconfig(name, options) {
};
};

/** @type {import('./index.d.ts').lilconfigSync} */
/** @type {import('./index').lilconfigSync} */
module.exports.lilconfigSync = function lilconfigSync(name, options) {
const {
ignoreEmptySearchPlaces,
Expand All @@ -327,7 +327,7 @@ module.exports.lilconfigSync = function lilconfigSync(name, options) {

return {
search(searchFrom = process.cwd()) {
/** @type {import('./index.d.ts').LilconfigResult} */
/** @type {import('./index').LilconfigResult} */
const result = {
config: null,
filepath: '',
Expand Down

0 comments on commit 2c68a1a

Please sign in to comment.