mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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.
This commit is contained in:
parent
9abd459b2a
commit
a7e3c2e09e
@ -41,7 +41,8 @@
|
|||||||
"install.js",
|
"install.js",
|
||||||
"typescript-if-required.js",
|
"typescript-if-required.js",
|
||||||
"cjs-entry.js",
|
"cjs-entry.js",
|
||||||
"cjs-entry-core.js"
|
"cjs-entry-core.js",
|
||||||
|
"cjs-entry.d.ts"
|
||||||
],
|
],
|
||||||
"author": "The Chromium Authors",
|
"author": "The Chromium Authors",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user