From 874d3bd1152b0830a7d9ffa25755e7d20257a2b2 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Fri, 23 May 2025 17:52:03 +0200 Subject: [PATCH 1/4] WIP: Deprecate Js namespace --- runtime/Js.res | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/runtime/Js.res b/runtime/Js.res index e1bfdcd334..f77d00926e 100644 --- a/runtime/Js.res +++ b/runtime/Js.res @@ -173,65 +173,91 @@ module Map = Js_map module WeakMap = Js_weakmap /** JS object type */ +@deprecated("Use `{..}` instead") type t<'a> = {..} as 'a /** JS global object reference */ +@deprecated("Use Stdlib.globalThis instead") @val external globalThis: t<'a> = "globalThis" -@unboxed +@deprecated("Use Stdlib.null instead") @unboxed type null<+'a> = Js_null.t<'a> = Value('a) | @as(null) Null +@deprecated("Use Stdlib.undefined instead") type undefined<+'a> = Js_undefined.t<'a> -@unboxed +@deprecated("Use Stdlib.nullable instead") @unboxed type nullable<+'a> = Js_null_undefined.t<'a> = Value('a) | @as(null) Null | @as(undefined) Undefined +@deprecated("Use Stdlib.nullable instead") type null_undefined<+'a> = nullable<'a> +@deprecated("Use Stdlib.Nullable.toOption instead") external toOption: nullable<'a> => option<'a> = "%nullable_to_opt" +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_option.fromUndefined") external undefinedToOption: undefined<'a> => option<'a> = "%undefined_to_opt" +@deprecated("Use Stdlib.Null.toOption instead") external nullToOption: null<'a> => option<'a> = "%null_to_opt" +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.isNullable") external isNullable: nullable<'a> => bool = "%is_nullable" +@deprecated("Use Stdlib.import instead") external import: 'a => promise<'a> = "%import" /** The same as {!test} except that it is more permissive on the types of input */ +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.testAny") external testAny: 'a => bool = "%is_nullable" /** The promise type, defined here for interoperation across packages. */ +@deprecated("Use Stdlib.Promise.t instead") type promise<+'a, +'e> /** The same as empty in `Js.Null`. Compiles to `null`. */ +@deprecated("Use Stdlib.null instead") external null: null<'a> = "%null" /** The same as empty `Js.Undefined`. Compiles to `undefined`. */ +@deprecated("Use Stdlib.undefined instead") external undefined: undefined<'a> = "%undefined" /** `typeof x` will be compiled as `typeof x` in JS. Please consider functions in `Js.Types` for a type safe way of reflection. */ +@deprecated("Use Stdlib.typeof instead") external typeof: 'a => string = "%typeof" -@val @scope("console") /** Equivalent to console.log any value. */ +/** Equivalent to console.log any value. */ +@deprecated("Use Stdlib.Console.log instead") +@val +@scope("console") external log: 'a => unit = "log" -@val @scope("console") external log2: ('a, 'b) => unit = "log" -@val @scope("console") external log3: ('a, 'b, 'c) => unit = "log" - -@val @scope("console") external log4: ('a, 'b, 'c, 'd) => unit = "log" +@deprecated("Use Stdlib.Console.log2 instead") @val @scope("console") +external log2: ('a, 'b) => unit = "log" +@deprecated("Use Stdlib.Console.log3 instead") @val @scope("console") +external log3: ('a, 'b, 'c) => unit = "log" +@deprecated("Use Stdlib.Console.log4 instead") @val @scope("console") +external log4: ('a, 'b, 'c, 'd) => unit = "log" -@val @scope("console") @variadic /** A convenience function to console.log more than 4 arguments */ +/** A convenience function to console.log more than 4 arguments */ +@deprecated("Use Stdlib.Console.logMany instead") +@val +@scope("console") +@variadic external logMany: array<'a> => unit = "log" +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.eqNull") external eqNull: ('a, null<'a>) => bool = "%equal_null" +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.eqUndefined") external eqUndefined: ('a, undefined<'a>) => bool = "%equal_undefined" +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.eqNullable") external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" /* ## Operators */ @@ -241,22 +267,26 @@ external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" It is marked as unsafe, since it is impossible to give a proper semantics for comparision which applies to any type */ +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.lt") external unsafe_lt: ('a, 'a) => bool = "%unsafe_lt" /** `unsafe_le(a, b)` will be compiled as `a <= b`. See also `Js.unsafe_lt`. */ +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.le") external unsafe_le: ('a, 'a) => bool = "%unsafe_le" /** `unsafe_gt(a, b)` will be compiled as `a > b`. See also `Js.unsafe_lt`. */ +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.gt") external unsafe_gt: ('a, 'a) => bool = "%unsafe_gt" /** `unsafe_ge(a, b)` will be compiled as `a >= b`. See also `Js.unsafe_lt`. */ +@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.ge") external unsafe_ge: ('a, 'a) => bool = "%unsafe_ge" From e51c48bbb3eae0b0f34bc40f88c96405b29a5c62 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Fri, 23 May 2025 18:01:36 +0200 Subject: [PATCH 2/4] Drop prefix --- runtime/Js.res | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/runtime/Js.res b/runtime/Js.res index f77d00926e..b6ed82084b 100644 --- a/runtime/Js.res +++ b/runtime/Js.res @@ -177,31 +177,31 @@ module WeakMap = Js_weakmap type t<'a> = {..} as 'a /** JS global object reference */ -@deprecated("Use Stdlib.globalThis instead") +@deprecated("Use globalThis instead") @val external globalThis: t<'a> = "globalThis" -@deprecated("Use Stdlib.null instead") @unboxed +@deprecated("Use null instead") @unboxed type null<+'a> = Js_null.t<'a> = Value('a) | @as(null) Null -@deprecated("Use Stdlib.undefined instead") +@deprecated("Use undefined instead") type undefined<+'a> = Js_undefined.t<'a> -@deprecated("Use Stdlib.nullable instead") @unboxed +@deprecated("Use nullable instead") @unboxed type nullable<+'a> = Js_null_undefined.t<'a> = Value('a) | @as(null) Null | @as(undefined) Undefined -@deprecated("Use Stdlib.nullable instead") +@deprecated("Use nullable instead") type null_undefined<+'a> = nullable<'a> -@deprecated("Use Stdlib.Nullable.toOption instead") +@deprecated("Use Nullable.toOption instead") external toOption: nullable<'a> => option<'a> = "%nullable_to_opt" @deprecated("FIXME: No equivalent in Stdlib, just Primitive_option.fromUndefined") external undefinedToOption: undefined<'a> => option<'a> = "%undefined_to_opt" -@deprecated("Use Stdlib.Null.toOption instead") +@deprecated("Use Null.toOption instead") external nullToOption: null<'a> => option<'a> = "%null_to_opt" @deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.isNullable") external isNullable: nullable<'a> => bool = "%is_nullable" -@deprecated("Use Stdlib.import instead") +@deprecated("Use import instead") external import: 'a => promise<'a> = "%import" /** The same as {!test} except that it is more permissive on the types of input */ @@ -211,43 +211,43 @@ external testAny: 'a => bool = "%is_nullable" /** The promise type, defined here for interoperation across packages. */ -@deprecated("Use Stdlib.Promise.t instead") +@deprecated("Use Promise.t instead") type promise<+'a, +'e> /** The same as empty in `Js.Null`. Compiles to `null`. */ -@deprecated("Use Stdlib.null instead") +@deprecated("Use null instead") external null: null<'a> = "%null" /** The same as empty `Js.Undefined`. Compiles to `undefined`. */ -@deprecated("Use Stdlib.undefined instead") +@deprecated("Use undefined instead") external undefined: undefined<'a> = "%undefined" /** `typeof x` will be compiled as `typeof x` in JS. Please consider functions in `Js.Types` for a type safe way of reflection. */ -@deprecated("Use Stdlib.typeof instead") +@deprecated("Use typeof instead") external typeof: 'a => string = "%typeof" /** Equivalent to console.log any value. */ -@deprecated("Use Stdlib.Console.log instead") +@deprecated("Use Console.log instead") @val @scope("console") external log: 'a => unit = "log" -@deprecated("Use Stdlib.Console.log2 instead") @val @scope("console") +@deprecated("Use Console.log2 instead") @val @scope("console") external log2: ('a, 'b) => unit = "log" -@deprecated("Use Stdlib.Console.log3 instead") @val @scope("console") +@deprecated("Use Console.log3 instead") @val @scope("console") external log3: ('a, 'b, 'c) => unit = "log" -@deprecated("Use Stdlib.Console.log4 instead") @val @scope("console") +@deprecated("Use Console.log4 instead") @val @scope("console") external log4: ('a, 'b, 'c, 'd) => unit = "log" /** A convenience function to console.log more than 4 arguments */ -@deprecated("Use Stdlib.Console.logMany instead") +@deprecated("Use Console.logMany instead") @val @scope("console") @variadic From c5a86a4e76cfc7c5beaab50e56bf8d6ecb33cf6b Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Fri, 23 May 2025 19:30:57 +0200 Subject: [PATCH 3/4] We'll just remove weird stuff in v13 --- runtime/Js.res | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/Js.res b/runtime/Js.res index b6ed82084b..4e8c010b39 100644 --- a/runtime/Js.res +++ b/runtime/Js.res @@ -195,17 +195,17 @@ type null_undefined<+'a> = nullable<'a> @deprecated("Use Nullable.toOption instead") external toOption: nullable<'a> => option<'a> = "%nullable_to_opt" -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_option.fromUndefined") +@deprecated("Will be removed in v13") external undefinedToOption: undefined<'a> => option<'a> = "%undefined_to_opt" @deprecated("Use Null.toOption instead") external nullToOption: null<'a> => option<'a> = "%null_to_opt" -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.isNullable") +@deprecated("Use Null.isNullable instead") external isNullable: nullable<'a> => bool = "%is_nullable" @deprecated("Use import instead") external import: 'a => promise<'a> = "%import" /** The same as {!test} except that it is more permissive on the types of input */ -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.testAny") +@deprecated("Will be removed in v13") external testAny: 'a => bool = "%is_nullable" /** @@ -253,11 +253,11 @@ external log4: ('a, 'b, 'c, 'd) => unit = "log" @variadic external logMany: array<'a> => unit = "log" -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.eqNull") +@deprecated("Will be removed in v13") external eqNull: ('a, null<'a>) => bool = "%equal_null" -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.eqUndefined") +@deprecated("Will be removed in v13") external eqUndefined: ('a, undefined<'a>) => bool = "%equal_undefined" -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.eqNullable") +@deprecated("Will be removed in v13") external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" /* ## Operators */ @@ -267,26 +267,26 @@ external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" It is marked as unsafe, since it is impossible to give a proper semantics for comparision which applies to any type */ -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.lt") +@deprecated("Will be removed in v13") external unsafe_lt: ('a, 'a) => bool = "%unsafe_lt" /** `unsafe_le(a, b)` will be compiled as `a <= b`. See also `Js.unsafe_lt`. */ -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.le") +@deprecated("Will be removed in v13") external unsafe_le: ('a, 'a) => bool = "%unsafe_le" /** `unsafe_gt(a, b)` will be compiled as `a > b`. See also `Js.unsafe_lt`. */ -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.gt") +@deprecated("Will be removed in v13") external unsafe_gt: ('a, 'a) => bool = "%unsafe_gt" /** `unsafe_ge(a, b)` will be compiled as `a >= b`. See also `Js.unsafe_lt`. */ -@deprecated("FIXME: No equivalent in Stdlib, just Primitive_js_extern.ge") +@deprecated("Will be removed in v13") external unsafe_ge: ('a, 'a) => bool = "%unsafe_ge" From 4e93db93e20de71df57145998f6df9913e229a56 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Fri, 23 May 2025 19:39:34 +0200 Subject: [PATCH 4/4] Quote values --- runtime/Js.res | 54 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/runtime/Js.res b/runtime/Js.res index 4e8c010b39..aa12d433fa 100644 --- a/runtime/Js.res +++ b/runtime/Js.res @@ -177,87 +177,87 @@ module WeakMap = Js_weakmap type t<'a> = {..} as 'a /** JS global object reference */ -@deprecated("Use globalThis instead") +@deprecated("Use `globalThis` instead") @val external globalThis: t<'a> = "globalThis" -@deprecated("Use null instead") @unboxed +@deprecated("Use `null` instead") @unboxed type null<+'a> = Js_null.t<'a> = Value('a) | @as(null) Null -@deprecated("Use undefined instead") +@deprecated("Use `undefined` instead") type undefined<+'a> = Js_undefined.t<'a> -@deprecated("Use nullable instead") @unboxed +@deprecated("Use `nullable` instead") @unboxed type nullable<+'a> = Js_null_undefined.t<'a> = Value('a) | @as(null) Null | @as(undefined) Undefined -@deprecated("Use nullable instead") +@deprecated("Use `nullable` instead") type null_undefined<+'a> = nullable<'a> -@deprecated("Use Nullable.toOption instead") +@deprecated("Use `Nullable.toOption` instead") external toOption: nullable<'a> => option<'a> = "%nullable_to_opt" -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external undefinedToOption: undefined<'a> => option<'a> = "%undefined_to_opt" -@deprecated("Use Null.toOption instead") +@deprecated("Use `Null.toOption` instead") external nullToOption: null<'a> => option<'a> = "%null_to_opt" -@deprecated("Use Null.isNullable instead") +@deprecated("Use `Null.isNullable` instead") external isNullable: nullable<'a> => bool = "%is_nullable" -@deprecated("Use import instead") +@deprecated("Use `import` instead") external import: 'a => promise<'a> = "%import" /** The same as {!test} except that it is more permissive on the types of input */ -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external testAny: 'a => bool = "%is_nullable" /** The promise type, defined here for interoperation across packages. */ -@deprecated("Use Promise.t instead") +@deprecated("Use `Promise.t` instead") type promise<+'a, +'e> /** The same as empty in `Js.Null`. Compiles to `null`. */ -@deprecated("Use null instead") +@deprecated("Use `null` instead") external null: null<'a> = "%null" /** The same as empty `Js.Undefined`. Compiles to `undefined`. */ -@deprecated("Use undefined instead") +@deprecated("Use `undefined` instead") external undefined: undefined<'a> = "%undefined" /** `typeof x` will be compiled as `typeof x` in JS. Please consider functions in `Js.Types` for a type safe way of reflection. */ -@deprecated("Use typeof instead") +@deprecated("Use `typeof` instead") external typeof: 'a => string = "%typeof" /** Equivalent to console.log any value. */ -@deprecated("Use Console.log instead") +@deprecated("Use `Console.log` instead") @val @scope("console") external log: 'a => unit = "log" -@deprecated("Use Console.log2 instead") @val @scope("console") +@deprecated("Use `Console.log2` instead") @val @scope("console") external log2: ('a, 'b) => unit = "log" -@deprecated("Use Console.log3 instead") @val @scope("console") +@deprecated("Use `Console.log3` instead") @val @scope("console") external log3: ('a, 'b, 'c) => unit = "log" -@deprecated("Use Console.log4 instead") @val @scope("console") +@deprecated("Use `Console.log4` instead") @val @scope("console") external log4: ('a, 'b, 'c, 'd) => unit = "log" /** A convenience function to console.log more than 4 arguments */ -@deprecated("Use Console.logMany instead") +@deprecated("Use `Console.logMany` instead") @val @scope("console") @variadic external logMany: array<'a> => unit = "log" -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external eqNull: ('a, null<'a>) => bool = "%equal_null" -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external eqUndefined: ('a, undefined<'a>) => bool = "%equal_undefined" -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" /* ## Operators */ @@ -267,26 +267,26 @@ external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" It is marked as unsafe, since it is impossible to give a proper semantics for comparision which applies to any type */ -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external unsafe_lt: ('a, 'a) => bool = "%unsafe_lt" /** `unsafe_le(a, b)` will be compiled as `a <= b`. See also `Js.unsafe_lt`. */ -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external unsafe_le: ('a, 'a) => bool = "%unsafe_le" /** `unsafe_gt(a, b)` will be compiled as `a > b`. See also `Js.unsafe_lt`. */ -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external unsafe_gt: ('a, 'a) => bool = "%unsafe_gt" /** `unsafe_ge(a, b)` will be compiled as `a >= b`. See also `Js.unsafe_lt`. */ -@deprecated("Will be removed in v13") +@deprecated("Do not use. This will be removed in v13") external unsafe_ge: ('a, 'a) => bool = "%unsafe_ge"