Currently, I am in the process of testing some TypeScript definitions that I created for a Node project that lacks them. These definitions are functioning properly when included in my project that utilizes the target Node project as well as when placed in my own folder within node_modules/@types/
(
node_modules/@types/chrome-aws-lambda/index.d.ts
). The setup involves Node 8.10, npm 5.6, and TypeScript 3.1.
Despite this, I have forked the module's repository from GitHub with the intention of incorporating it into the project for wider usage. To achieve this, I modified the package.json file of the forked project to direct types
to
source/index.d.ts</code which is located alongside the <code>main
file, source/index.js</code. Subsequently, I linked it in my project using <code>npm link ../chrome-aws-lambda
.
Unfortunately, this approach is not successful. When running tsc
, an error is returned stating:
error TS2307: Cannot find module 'chrome-aws-lambda'
When executed with --traceResolution
, it seems like the module is not being sought after at all.
I suspect that the issue may be related to the package not truly being 'installed'. Attempting to manually copy the project directory into the node_modules
instead of linking it did not resolve the problem. I also considered that TypeScript might not be recognizing the types
field in the package.json
, so I added one in the root since that is the default behavior. Additionally, I verified if it was being included by adding it to the include section of my .tsconfig
. Further adjustments were made to baseUrl
, paths
, typeRoots
, and moduleResolution
in the configuration file without success.
All these efforts have been futile.
Prior to submitting a PR, I need confirmation whether the solution is effective or not. Any guidance on how to proceed would be greatly appreciated. If additional information is required, please do not hesitate to request! Below, you will find the index.d.ts
along with the import statement provided, just in case there is an oversight in that area.
Thank you!
index.d.ts:
declare module 'chrome-aws-lambda' {
import * as Puppeteer from 'puppeteer';
export default class Chromium {
static args : Array<string>;
static defaultViewport : {
width : number,
height : number,
deviceScaleFactor : number,
isMobile : boolean,
hasTouch : boolean,
isLandscape : boolean
};
static executablePath : Promise<string>;
static headless : boolean;
static puppeteer : typeof Puppeteer;
}
}
Furthermore, here is the import statement in question:
import Chromium from 'chrome-aws-lambda';