ts-declaration-location
v1.0.4
Published
Determine where a ts type declaration comes from
Downloads
831,793
Readme
ts-declaration-location
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);
}