Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Blob type is incompatible with node definition of Blob #53668

Closed
jeswr opened this issue Apr 5, 2023 · 7 comments
Closed

Blob type is incompatible with node definition of Blob #53668

jeswr opened this issue Apr 5, 2023 · 7 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@jeswr
Copy link

jeswr commented Apr 5, 2023

lib Update Request

Configuration Check

My config is the default config created by running npm init -y && npx tsc --init. No packages have been installed.

Node Version: v19.3.0
NPM Version: 9.6.2

Missing / Incorrect Definition

The Blob type defined here https://github.com/microsoft/TypeScript/blob/e83d61398ea0e4231e882121dd6c6bcfe4fdc9e4/src/lib/dom.generated.d.ts#L3075 is not assignable to the Blob type in node here https://github.com/DefinitelyTyped/DefinitelyTyped/blob/ec8923e261d3619aef6a4663d50159e7e0dcf3e9/types/node/buffer.d.ts#L121 due to type applied to the prototype.

Sample Code

import { Blob as BufferBlob } from "buffer";
const bl: Blob = new BufferBlob([]);

Causes the typescript compilation error

Property 'prototype' is missing in type 'import("buffer").Blob' but required in type 'Blob'.ts(2741)
lib.dom.d.ts(2591, 5): 'prototype' is declared here.
@fatcerberus
Copy link

The default config includes the DOM (i.e. web browser API) types; since you're targeting Node, you should install @types/node if you haven't already and then write a lib entry in your tsconfig that doesn't include dom. It is known that the DOM types are incompatible with @types/node.

@RyanCavanaugh RyanCavanaugh added the External Relates to another program, environment, or user action which we cannot control. label Apr 5, 2023
@RyanCavanaugh
Copy link
Member

It sounds like this is a problem in the node .d.ts, not the DOM's.

@MartinJohns
Copy link
Contributor

@RyanCavanaugh isn't this essentially the same as #52166?

@typescript-bot
Copy link
Collaborator

This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@jeswr
Copy link
Author

jeswr commented Apr 11, 2023

In light of this response can this issue be re-opened and addressed as part of the 5.1.0 milestone along with #52166 and any other vars that may have the same regression.

@jeswr

This comment was marked as duplicate.

@jeswr
Copy link
Author

jeswr commented Apr 30, 2023

@RyanCavanaugh can this issue please be re-opened per #53668 (comment)

jeswr added a commit to inrupt/solid-client-js that referenced this issue May 8, 2023
As discussed in microsoft/TypeScript#53668
the @types/node definition of a buffer is looser and hence we should
use that in order to be compaible with web buffer types and node
buffer types
jeswr added a commit to inrupt/solid-client-js that referenced this issue May 10, 2023
* fix: use @types/node buffer type rather than lib.dom.ts

As discussed in microsoft/TypeScript#53668
the @types/node definition of a buffer is looser and hence we should
use that in order to be compaible with web buffer types and node
buffer types

* chore: run lint:fix

* chore: test saveFileInContainer for buffers

* chore: test buffers on overwriteFile

* chore: don't test blob on node 14

* chore: update changelog for new buffer definition

* Update e2e/node/resource.test.ts

Co-authored-by: Zwifi <nseydoux@inrupt.com>

* Update CHANGELOG.md

Co-authored-by: Zwifi <nseydoux@inrupt.com>

* chore: cleanup tests from review

* chore: remove unecessary type casting

---------

Co-authored-by: Zwifi <nseydoux@inrupt.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

5 participants