ycjcl868 / git-local-info

🗝get current sha, branch name, repository, commit info from a git repo without relying on the git command.
4 stars 1 forks source link

TS Types are not getting detected #1

Open yorch opened 2 years ago

yorch commented 2 years ago

Seems like types / typings property in package.json is missing, so VSCode cannot properly locate the TS types for the package:

image

More info: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package

Thanks!

yorch commented 2 years ago

My current workaround is to import the types manually like:

// @ts-expect-error - Error in the dependency: https://github.com/ycjcl868/git-local-info/issues/1
import GitInfo from 'git-local-info';
import type { IGitInfo } from 'git-local-info/lib/typings';

export const getGitInfo = () => {
  const gitInfo = new GitInfo();

  return gitInfo.getGitInfo as IGitInfo;
};
yorch commented 1 year ago

Created a fork to address this problem and release it as git-local-info-ts