Skip to content

Commit 27734eb

Browse files
committed
fix Error constructor mix up
1 parent 0408064 commit 27734eb

File tree

3 files changed

+83
-70
lines changed

3 files changed

+83
-70
lines changed

.changeset/old-rules-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"rescript-bun": patch
3+
---
4+
5+
Move `responseRedirect` out of global scope, to stop mix up with result.Error constructor.

src/Bun.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,8 @@ module Secrets = {
25262526
* Binds to Bun's `S3Client` and default `Bun.s3` instance.
25272527
*/
25282528
module S3 = {
2529+
@@warning("-30")
2530+
25292531
/**
25302532
* Configuration for S3 operations
25312533
*/

src/Globals.res

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,6 @@ type requestMode =
845845
| @as("no-cors") NoCors
846846
| @as("same-origin") SameOriginMode
847847

848-
type requestRedirect =
849-
| @as("error") Error
850-
| @as("follow") Follow
851-
| @as("manual") Manual
852-
853848
type referrerPolicy =
854849
| @as("") Empty
855850
| @as("no-referrer") NoReferrer
@@ -899,104 +894,89 @@ module BodyInit = {
899894
external makeFromURLSearchParams: URLSearchParams.t => t = "%identity"
900895
}
901896

902-
type requestInit = {
903-
/**
897+
type checkServerIdentity
898+
899+
type tlsConfig = {rejectUnauthorized?: bool} // Defaults to true
900+
901+
type fetchRequestInitTls = {
902+
...tlsConfig,
903+
checkServerIdentity?: checkServerIdentity, // TODO: change `any` to `checkServerIdentity`
904+
}
905+
906+
/** All possible HTTP methods. */
907+
type method = GET | HEAD | POST | PUT | DELETE | CONNECT | OPTIONS | TRACE | PATCH
908+
909+
// https://github.com/oven-sh/bun/blob/main/packages/bun-types/globals.d.ts#L1331
910+
module Request = {
911+
type t
912+
913+
type requestRedirect =
914+
| @as("error") Error
915+
| @as("follow") Follow
916+
| @as("manual") Manual
917+
918+
type requestInit = {
919+
/**
904920
* A BodyInit object or null to set request's body.
905921
*/
906-
body?: Null.t<BodyInit.t>,
907-
/**
922+
body?: Null.t<BodyInit.t>,
923+
/**
908924
* A string indicating how the request will interact with the browser's cache to set request's cache.
909925
*
910926
* Note: as of Bun v0.5.7, this is not implemented yet.
911927
*/
912-
cache?: requestCache,
913-
/**
928+
cache?: requestCache,
929+
/**
914930
* A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
915931
*/
916-
credentials?: requestCredentials,
917-
/**
932+
credentials?: requestCredentials,
933+
/**
918934
* A Headers object, an object literal, or an array of two-item arrays to set request's headers.
919935
*/
920-
headers?: HeadersInit.t,
921-
/**
936+
headers?: HeadersInit.t,
937+
/**
922938
* A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
923939
*
924940
* Note: as of Bun v0.5.7, this is not implemented yet.
925941
*/
926-
integrity?: string,
927-
/**
942+
integrity?: string,
943+
/**
928944
* A boolean to set request's keepalive.
929945
*
930946
* Available in Bun v0.2.0 and above.
931947
*
932948
* This is enabled by default
933949
*/
934-
keepalive?: bool,
935-
/**
950+
keepalive?: bool,
951+
/**
936952
* A string to set request's method.
937953
*/
938-
method?: string,
939-
/**
954+
method?: string,
955+
/**
940956
* A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
941957
*/
942-
mode?: requestMode,
943-
/**
958+
mode?: requestMode,
959+
/**
944960
* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.
945961
*/
946-
redirect?: requestRedirect,
947-
/**
962+
redirect?: requestRedirect,
963+
/**
948964
* A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
949965
*/
950-
referrer?: string,
951-
/**
966+
referrer?: string,
967+
/**
952968
* A referrer policy to set request's referrerPolicy.
953969
*/
954-
referrerPolicy?: referrerPolicy,
955-
/**
970+
referrerPolicy?: referrerPolicy,
971+
/**
956972
* An AbortSignal to set request's signal.
957973
*/
958-
signal?: Null.t<AbortSignal.t>,
959-
/**
974+
signal?: Null.t<AbortSignal.t>,
975+
/**
960976
* Enable or disable HTTP request timeout
961977
*/
962-
timeout?: bool,
963-
}
964-
965-
type checkServerIdentity
966-
967-
type tlsConfig = {rejectUnauthorized?: bool} // Defaults to true
968-
969-
type fetchRequestInitTls = {
970-
...tlsConfig,
971-
checkServerIdentity?: checkServerIdentity, // TODO: change `any` to `checkServerIdentity`
972-
}
973-
974-
type fetchRequestInit = {
975-
...requestInit,
976-
/**
977-
* Log the raw HTTP request & response to stdout. This API may be
978-
* removed in a future version of Bun without notice.
979-
* This is a custom property that is not part of the Fetch API specification.
980-
* It exists mostly as a debugging tool
981-
*/
982-
verbose?: bool,
983-
/**
984-
* Override http_proxy or HTTPS_PROXY
985-
* This is a custom property that is not part of the Fetch API specification.
986-
*/
987-
proxy?: string,
988-
/**
989-
* Override the default TLS options
990-
*/
991-
tls?: fetchRequestInitTls,
992-
}
993-
994-
/** All possible HTTP methods. */
995-
type method = GET | HEAD | POST | PUT | DELETE | CONNECT | OPTIONS | TRACE | PATCH
996-
997-
// https://github.com/oven-sh/bun/blob/main/packages/bun-types/globals.d.ts#L1331
998-
module Request = {
999-
type t
978+
timeout?: bool,
979+
}
1000980

1001981
/**
1002982
* Read or write the HTTP headers for this request.
@@ -1174,6 +1154,32 @@ module Request = {
11741154
external makeFromRequest: (t, ~requestInit: requestInit=?) => t = "Request"
11751155
}
11761156

1157+
@deprecated({
1158+
reason: "Use Request.requestRedirect instead",
1159+
migrate: %replace.type(: Request.requestRedirect),
1160+
})
1161+
type requestRedirect = Request.requestRedirect
1162+
1163+
type fetchRequestInit = {
1164+
...Request.requestInit,
1165+
/**
1166+
* Log the raw HTTP request & response to stdout. This API may be
1167+
* removed in a future version of Bun without notice.
1168+
* This is a custom property that is not part of the Fetch API specification.
1169+
* It exists mostly as a debugging tool
1170+
*/
1171+
verbose?: bool,
1172+
/**
1173+
* Override http_proxy or HTTPS_PROXY
1174+
* This is a custom property that is not part of the Fetch API specification.
1175+
*/
1176+
proxy?: string,
1177+
/**
1178+
* Override the default TLS options
1179+
*/
1180+
tls?: fetchRequestInitTls,
1181+
}
1182+
11771183
module Crypto = {
11781184
type t
11791185

@@ -1363,7 +1369,7 @@ external performance: performance = "performance"
13631369
*
13641370
*
13651371
*/
1366-
external fetchByRequest: (Request.t, ~init: requestInit=?) => promise<Response.t> = "fetch"
1372+
external fetchByRequest: (Request.t, ~init: Request.requestInit=?) => promise<Response.t> = "fetch"
13671373
/**
13681374
* Send a HTTP(s) request
13691375
*

0 commit comments

Comments
 (0)