Skip to content

Commit 5dc6503

Browse files
🤖 Merge PR DefinitelyTyped#72537 [@rails/activestorage] Update types for @rails/activestorage v8.0 by @victoria-huang
1 parent 0f98359 commit 5dc6503

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

‎types/rails__activestorage/index.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class DirectUpload {
99

1010
constructor(file: File, url: string, delegate?: DirectUploadDelegate, customHeaders?: Record<string, string>);
1111

12-
create(callback: (error: Error, blob: Blob) => void): void;
12+
create(callback: (error: Error | null, blob?: Blob) => void): void;
1313
}
1414

1515
export interface DirectUploadDelegate {

‎types/rails__activestorage/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/rails__activestorage",
4-
"version": "7.1.9999",
4+
"version": "8.0.9999",
55
"projects": [
66
"https://github.com/rails/rails/tree/master/activestorage/app/javascript",
77
"http://rubyonrails.org/"

‎types/rails__activestorage/rails__activestorage-tests.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ const d = new ActiveStorage.DirectUpload(
2525
customHeaders,
2626
);
2727

28-
d.create((error, blob) => {
28+
d.create((error: Error | null) => {
2929
if (error) {
3030
console.log(error.message);
31-
} else {
31+
}
32+
});
33+
34+
d.create((error: Error | null, blob?: ActiveStorage.Blob) => {
35+
if (error) {
36+
console.log(error.message);
37+
} else if (blob) {
3238
const { byte_size, checksum, content_type, filename, signed_id } = blob;
3339
console.log({ byte_size, checksum, content_type, filename, signed_id });
3440
}

0 commit comments

Comments
 (0)