Say I have a project X with the following in its package.json:
"typings": "lib/index.d.ts",
"types": "lib/index.d.ts",
I want to import all of the types from the index.d.ts file into another project.
the index.d.ts file looks like:
export declare const makePathExecutable: (runPath: string, cb: Function) => void;
export declare const checkForEquality: (arr1: string[], arr2: string[]) => boolean;
export declare const arrayHasDuplicates: (a: any[]) => boolean;
export declare const isStringWithPositiveLn: (s: string) => boolean;
export declare const findNearestRunAndTransform: (root: string, pth: string, cb: Function) => any;
export declare const findSumanMarkers: (types: string[], root: string, files: string[], cb: IMapCallback) => void;
export declare const isObject: (v: any) => boolean;
In my other project, I attempt to import these types like so:
import * as X from "x"
but this doesn't really seem to work.
What is the right way to import these types?
Your project
xdoes not declare the types separately from the values. So to access the type, you need to usetypeof: