1.0.1 • Published 2 days ago

ts-declaration-location v1.0.1

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
2 days ago

ts-declaration-location

npm version CI Coverage Status\ code style: prettier GitHub Discussions BSD 3 Clause license Commitizen friendly semantic-release

Donate

Any donations would be much appreciated. 😄

Installation

# Install with npm
npm install -D ts-declaration-location

# Install with pnpm
pnpm add -D ts-declaration-location

# Install with yarn
yarn add -D ts-declaration-location

Usage Example

import typeMatchesSpecifier from "ts-declaration-location";
import type ts from "typescript";

function isTypeFromSomePackage(program: ts.Program, type: ts.Type) {
  const specifier = {
    from: "package",
    package: "some-package"
  };

  return typeMatchesSpecifier(program, specifier, type);
}

function isTypeFromSomeFile(program: ts.Program, type: ts.Type) {
  const specifier = {
    from: "file",
    path: "src/**/some.ts"
  };

  return typeMatchesSpecifier(program, specifier, type);
}

function isTypeFromTSLib(program: ts.Program, type: ts.Type) {
  const specifier = {
    from: "lib",
  };

  return typeMatchesSpecifier(program, specifier, type);
}
1.0.1

2 days ago

1.0.0

24 days ago