Closed jjangga0214 closed 1 year ago
I cannot use ESM pure versions(>=8) yet, so currently stick with v7.0.1.
And it has a problem that implementation and typing are different.
Its typing is the snippet below.
import {Except} from 'type-fest'; import {readPackage, readPackageSync, Options as ReadPackageOptions, NormalizeOptions as ReadPackageNormalizeOptions, PackageJson, NormalizedPackageJson} from 'read-pkg'; export type Options = { /** The directory to start looking for a package.json file. @default process.cwd() */ cwd?: URL | string; } & Except<ReadPackageOptions, 'cwd'>; export type NormalizeOptions = { /** The directory to start looking for a package.json file. @default process.cwd() */ cwd?: URL | string; } & Except<ReadPackageNormalizeOptions, 'cwd'>; export interface ReadResult { packageJson: PackageJson; path: string; } export interface NormalizedReadResult { packageJson: NormalizedPackageJson; path: string; } export { PackageJson, NormalizedPackageJson, }; /** Read the closest `package.json` file. @example `` import {readPackageUp} from 'read-pkg-up'; console.log(await readPackageUp()); // { // packageJson: { // name: 'awesome-package', // version: '1.0.0', // … // }, // path: '/Users/sindresorhus/dev/awesome-package/package.json' // } `` */ export function readPackageUp(options?: NormalizeOptions): Promise<NormalizedReadResult | undefined>; export function readPackageUp(options: Options): Promise<ReadResult | undefined>; /** Synchronously read the closest `package.json` file. @example `` import {readPackageUpSync} from 'read-pkg-up'; console.log(readPackageUpSync()); // { // packageJson: { // name: 'awesome-package', // version: '1.0.0', // … // }, // path: '/Users/sindresorhus/dev/awesome-package/package.json' // } `` */ export function readPackageUpSync(options?: NormalizeOptions): NormalizedReadResult | undefined; export function readPackageUpSync(options: Options): ReadResult | undefined;
This requires me to do import by the member.
import { readPackageUp } from 'read-pkg-up' await readPackageUp()
However, an error occurs, because the implementation is different.
https://github.com/sindresorhus/read-pkg-up/blob/c92040fcf5f4080cf7a0668184771de52e37a10e/index.js#L6-L17
As module.exports is a function itself, I should import like the below snippet.
module.exports
import readPackageUp from 'read-pkg-up' await readPackageUp()
This time, a type error occurs, which requires me to // @ts-ignore.
// @ts-ignore
Would you publish v7.0.2 to fix this?
Thanks a lot.
Sorry, no plans to fix v7. I recommend moving to ESM and upgrading to the latest version.
https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
I cannot use ESM pure versions(>=8) yet, so currently stick with v7.0.1.
And it has a problem that implementation and typing are different.
Its typing is the snippet below.
This requires me to do import by the member.
However, an error occurs, because the implementation is different.
https://github.com/sindresorhus/read-pkg-up/blob/c92040fcf5f4080cf7a0668184771de52e37a10e/index.js#L6-L17
As
module.exports
is a function itself, I should import like the below snippet.This time, a type error occurs, which requires me to
// @ts-ignore
.Would you publish v7.0.2 to fix this?
Thanks a lot.