-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: support web-native streams for read/write methods #2849
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
base: master
Are you sure you want to change the base?
Conversation
import _ExcelJS from '../../index'; | ||
import type * as ExcelJSModule from '../../exceljs'; | ||
|
||
const ExcelJS = _ExcelJS as unknown as typeof ExcelJSModule; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type checking wasn't currently being picked up by ts-node due to ../../index
resolving to the untyped index files rather than ../../index.d.ts
.
https://stackoverflow.com/questions/62490423/consume-index-d-ts-declaration-file-in-source-code
It looks like you have a collision in your module resolution.
If you have a file called index.ts, then index.d.ts won't be automatically imported.
TypeScript will automatically import .d.ts files, UNLESS their name collides with other files, where the rules for what files will collide are somewhat described here: https://www.typescriptlang.org/docs/handbook/module-resolution.html .
For that reason, I've renamed index.d.ts
to exceljs.d.ts
(and updated the corresponding package.json fields etc).
It still needs to be imported in this weird way for the test though. Possibly there's a better fix, but I couldn't figure one out.
@@ -24,17 +27,21 @@ describe('typescript', () => { | |||
ws.getCell('A1').value = 7; | |||
|
|||
const wb2 = new ExcelJS.Workbook(); | |||
const stream = wb2.xlsx.createInputStream(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was previously failing due to removal of createInputStream
, so I've overwritten the existing test case rather than adding a new one.
], | ||
"scripts": { | ||
"test": "npm run test:full", | ||
"test:es5": "export EXCEL_BUILD=es5 && npm run test:full", | ||
"test:full": "npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine", | ||
"test:full": "npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine && npm run test:typescript", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TS tests to test:full
, which should now work as they no longer contain a failing test case.
Fixes #1228
Fixes #2753
Summary
Add support for
read(<web-native ReadableStream instance>)
andwrite(<web-native WritableStream instance>)
. Both have excellent support in modern browsers and are also implemented in NodeJS, Deno, and Bun.Test plan
See
spec/unit/xlsx/write-writable-stream.spec.js
and changes tospec/typescript/exceljs.spec.ts
.Related to source code (for typings update)
N/A (updated typings are reflected in diffs to runtime code + tests).