-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
TypeScript error on fresh install #6244
Comments
After doing some investigation, I came to the conclusion it couldn't be a problem with It's always the same code: typescript/lib/lib.dom.d.tsinterface Blob {
readonly size: number;
readonly type: string;
arrayBuffer(): Promise<ArrayBuffer>;
slice(start?: number, end?: number, contentType?: string): Blob;
stream(): ReadableStream<Uint8Array>;
text(): Promise<string>;
}
declare var Blob: {
prototype: Blob;
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
};
type BlobPart = BufferSource | Blob | string;
interface BlobPropertyBag {
endings?: EndingType;
type?: string;
}
type BufferSource = ArrayBufferView | ArrayBuffer;
type EndingType = "native" | "transparent";
interface File extends Blob {
readonly lastModified: number;
readonly name: string;
readonly webkitRelativePath: string;
}
declare var File: {
prototype: File;
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
};
interface FilePropertyBag extends BlobPropertyBag {
lastModified?: number;
} Using It seems like @vansergen introduced @types/node/buffer.d.tsexport interface FileOptions {
/**
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be
* converted to the platform native line-ending as specified by `require('node:os').EOL`.
*/
endings?: "native" | "transparent";
/** The File content-type. */
type?: string;
/** The last modified date of the file. `Default`: Date.now(). */
lastModified?: number;
}
/**
* A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files.
* @experimental
* @since v18.13.0
*/
export class File extends Blob {
constructor(
sources: Array<BinaryLike | Blob>,
fileName: string,
options?: FileOptions
);
/**
* The name of the `File`.
* @since v18.13.0
*/
readonly name: string;
/**
* The last modified date of the `File`.
* @since v18.13.0
*/
readonly lastModified: number;
} @types/node/crypto.d.tstype BinaryLike = string | NodeJS.ArrayBufferView; |
The issue is it doesn't extend the DOM types directly so it's missing the prototype. @pcattori do you know of a way to trick typescript into adding the prototype to a non-related class? |
Doing some more investigation, I landed on DefinitelyTyped/DefinitelyTyped#65049, which lead me to @pcattori's microsoft/TypeScript#52166 According to that issue, it doesn't seem to be a problem with As @pcattori pointed out: things are working as expected with TS 4.8.4 in our codebase (this is also confirmed after I did that in #6108) |
Did some further investigation and landed on #4371. Here @akomm points out (see #4371 (comment) & #4371 (comment)) that it would be a collision between Basically having types for any built-in Node module is causing this error. |
Can we just |
It would be probably better than blocked build or having to entirely disable typecheck on production build. But the types are actually wrong as the prototype isn't properly picked, so writing code that operates on the "wrong" types could lead to unexpected bugs. Just saying. It should be removed once the issue is resolved on the TS side. |
@jacob-ebey Adding The proper way would be to actually fix |
According to microsoft/TypeScript#52166:
Is it an option to roll the TS back to 4.8.4 in the Remix dependencies? |
@lpsinger One of the reasons we updated to V5 was to support @jacob-ebey Is there any other solution you can think of besides adding |
Duplicate of #4371 |
This is now fixed by #6108 and will be released in v2 |
What version of Remix are you using?
Latest
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Install a new Remix project & run
npm run typecheck
Expected Behavior
No type-errors would appear
Actual Behavior
This is the same error we got in #6108 & that @dpobel also reported in #6119 (comment)
The problem seemed to be that
NodeOnDiskFile
doesn't have aprototype
property, but after implementing that (in #6108), we still getSince @jacob-ebey is the creator of the class, maybe he can point me/us into the right direction here
I tried a lot, but I can't seem to find a solution to make this work tbh 🤔
The text was updated successfully, but these errors were encountered: