-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type definitions for acorn.mjs #954
Conversation
For TypeScript projects that use the acorn.mjs distribution bundle, a separate `.mjs.d.ts` needs to be added to the folder. This was suggested in microsoft/TypeScript#27957 (comment) In DevTools, we use this in https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2218015 to make it compile with TypeScript
Is it possible to reuse these definitions in |
Agreed, I really don't want to have two copies of the same file in the repository. |
Should be fixed now. Initially I tried to import the However, this would require users to add |
From a quick attempt, putting this in import acorn from "./acorn.js";
export = acorn; As far as I understand, it would also preserve backward compatibility - please correct me if I'm wrong and it's subject to the same issue. |
Yes it works, but I had to set |
Ah interesting. Not sure if there's a generic way to work around that... |
Actually... it seems that import * as acorn from "./acorn";
export = acorn; works just as well even without the flag? |
This removes the need for an extra tsconfig flag
I don't know why this now works, as I tried before. But yes, this removes the need for any tsconfig change AND is not a breaking change. Awesome, thanks! |
Great, thanks for the PR! |
The `.mjs.d.ts` file has been upstreamed in acornjs/acorn#954 as per the instructions in microsoft/TypeScript#27957 (comment) R=jacktfranklin@chromium.org,bmeurer@chromium.org Bug: 1011811 Change-Id: Ia2e0c3145318ac93b5e49d2b40780ffe7c469bab Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2218015 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
The `.mjs.d.ts` file has been upstreamed in acornjs/acorn#954 as per the instructions in microsoft/TypeScript#27957 (comment) R=jacktfranklin@chromium.org,bmeurer@chromium.org Bug: 1011811 Change-Id: Ia2e0c3145318ac93b5e49d2b40780ffe7c469bab Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2218015 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
For TypeScript projects that use the acorn.mjs distribution bundle,
a separate
.mjs.d.ts
needs to be added to the folder. This wassuggested in microsoft/TypeScript#27957 (comment)
In DevTools, we use this in https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2218015
to make it compile with TypeScript