From a7e3c2e09e9163eee2f15221aafa4400e6a75f91 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Thu, 4 Feb 2021 09:45:46 +0000 Subject: [PATCH] fix(typescript): ship .d.ts file in npm package (#6811) In all my excitement about shipping types, we forgot to export the actual `d.ts` file that makes it all happen... :( I didn't pick this up locally because I was testing with `npm link`, which does a symbolic link and therefore doesn't mirror the list of files that make it into the published package. To test this change, I made the change and ran `npm pack` to generate a tar. I then created a new empty directory and did `npm init -y` followed by `npm install path/to/puppeteer-7.tgz`. I then initialised TypeScript, and wrote this: ```js import puppeteer from 'puppeteer'; async function run() { const browser = await puppeteer.launch() const page = await browser.newPage() await page.goto('https://foo.com') } run(); ``` As I typed I got autocompletions and if I were to make an error, I'd get a TypeScript error. There is follow up work to be done because this unfortunately does not work if you use `require` rather than ES Modules. @AviVahl suggested a change in https://github.com/puppeteer/puppeteer/issues/6807 but I cannot get it to work, so I'd like to do more investigation here. In the mean time, whatever the contents of `cjs-entry.d.ts`, we should definitely be exporting it as part of the module, so this PR is still good to land. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 28b6f73a..7bd65c5e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "install.js", "typescript-if-required.js", "cjs-entry.js", - "cjs-entry-core.js" + "cjs-entry-core.js", + "cjs-entry.d.ts" ], "author": "The Chromium Authors", "license": "Apache-2.0",