Skip to content

Commit

Permalink
(Js.)Dict.t -> dict
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Oct 30, 2024
1 parent 3b93359 commit 3b7410f
Show file tree
Hide file tree
Showing 36 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion runtime/Dict.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t<'a> = Js.Dict.t<'a>
type t<'a> = dict<'a>

@get_index external getUnsafe: (t<'a>, string) => 'a = ""
@get_index external get: (t<'a>, string) => option<'a> = ""
Expand Down
6 changes: 3 additions & 3 deletions runtime/Dict.resi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Compiles to a regular JavaScript object.*/
/**
Type representing a dictionary of value `'a`.
*/
type t<'a> = Js.Dict.t<'a>
type t<'a> = dict<'a>

/**
`getUnsafe(dict, key)` Returns the `value` at the provided `key`.
Expand Down Expand Up @@ -71,7 +71,7 @@ let delete: (t<'a>, string) => unit
## Examples
```rescript
let dict1: Dict.t<int> = Dict.make() // You can annotate the type of the values of your dict yourself if you want
let dict1: dict<int> = Dict.make() // You can annotate the type of the values of your dict yourself if you want
let dict2 = Dict.make() // Or you can let ReScript infer it via usage.
dict2->Dict.set("someKey", 12)
Expand Down Expand Up @@ -99,7 +99,7 @@ external fromArray: array<(string, 'a)> => t<'a> = "Object.fromEntries"
// Pretend we have an iterator of the correct shape
@val external someIterator: Iterator.t<(string, int)> = "someIterator"
let dict = Dict.fromIterator(someIterator) // Dict.t<int>
let dict = Dict.fromIterator(someIterator) // dict<int>
```
*/
@val
Expand Down
10 changes: 5 additions & 5 deletions runtime/JSON.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type rec t = Js.Json.t =
| @as(null) Null
| String(string)
| Number(float)
| Object(Dict.t<t>)
| Object(dict<t>)
| Array(array<t>)

@unboxed
Expand Down Expand Up @@ -47,15 +47,15 @@ module Classify = {
| Null
| String(string)
| Number(float)
| Object(Dict.t<t>)
| Object(dict<t>)
| Array(array<t>)

@val external _internalClass: 'a => string = "Object.prototype.toString.call"
external _asBool: 'a => bool = "%identity"
external _asString: 'a => string = "%identity"
external _asFloat: 'a => float = "%identity"
external _asArray: 'a => array<Js.Json.t> = "%identity"
external _asDict: 'a => Dict.t<Js.Json.t> = "%identity"
external _asDict: 'a => dict<Js.Json.t> = "%identity"

let classify = value => {
switch _internalClass(value) {
Expand All @@ -75,7 +75,7 @@ module Encode = {
external string: string => t = "%identity"
external int: int => t = "%identity"
external float: float => t = "%identity"
external object: Dict.t<t> => t = "%identity"
external object: dict<t> => t = "%identity"
external array: array<t> => t = "%identity"
}

Expand All @@ -86,7 +86,7 @@ module Decode = {
let float = (json: t) => Type.typeof(json) === #number ? Some((Obj.magic(json): float)) : None
let object = (json: t) =>
if Type.typeof(json) === #object && !Array.isArray(json) && !(Obj.magic(json) === Null.null) {
Some((Obj.magic(json): Dict.t<t>))
Some((Obj.magic(json): dict<t>))
} else {
None
}
Expand Down
10 changes: 5 additions & 5 deletions runtime/JSON.resi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type rec t = Js.Json.t =
| @as(null) Null
| String(string)
| Number(float)
| Object(Dict.t<t>)
| Object(dict<t>)
| Array(array<t>)

@unboxed
Expand Down Expand Up @@ -578,7 +578,7 @@ module Classify: {
| Null
| String(string)
| Number(float)
| Object(Dict.t<t>)
| Object(dict<t>)
| Array(array<t>)

/**
Expand Down Expand Up @@ -660,7 +660,7 @@ module Encode: {
JSON.Encode.object(dict)
```
*/
external object: Dict.t<t> => t = "%identity"
external object: dict<t> => t = "%identity"

/**
Returns an array as a JSON object.
Expand Down Expand Up @@ -733,7 +733,7 @@ module Decode: {
let float: t => option<float>

/**
Decodes a single JSON value. If the value is an object, it will return `Some(Dict.t)` - otherwise it will return `None`.
Decodes a single JSON value. If the value is an object, it will return `Some(dict)` - otherwise it will return `None`.
## Examples
```rescript
Expand All @@ -744,7 +744,7 @@ module Decode: {
// None
```
*/
let object: t => option<Dict.t<t>>
let object: t => option<dict<t>>

/**
Decodes a single JSON value. If the value is an array, it will return `Some(array)` - otherwise it will return `None`.
Expand Down
4 changes: 2 additions & 2 deletions runtime/Js_json.resi
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ external number: float => t = "%identity"
/** `boolean(b)` makes a JSON boolean of the `bool` `b`. */
external boolean: bool => t = "%identity"

/** `object_(dict)` makes a JSON object of the `Js.Dict.t` `dict`. */
/** `object_(dict)` makes a JSON object of the `dict`. */
external object_: Js_dict.t<t> => t = "%identity"

/** `array_(a)` makes a JSON array of the `Js.Json.t` array `a`. */
Expand Down Expand Up @@ -178,7 +178,7 @@ let getIds = s => {
switch Js.Json.classify(json) {
| Js.Json.JSONObject(value) =>
/* In this branch, compiler infer value : Js.Json.t Js.Dict.t */
/* In this branch, compiler infer value : Js.Json.t dict */
switch Js.Dict.get(value, "ids") {
| Some(ids) =>
switch Js.Json.classify(ids) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
7 │ let d = (dict :> fakeDict<int>)
8 │

Type Js.Dict.t<int> = dict<int> is not a subtype of fakeDict<int>
Type dict<int> = dict<int> is not a subtype of fakeDict<int>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/gentype_tests/typescript-react-example/src/Core.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ let undefined0 = (x: Js.undefined<int>) => x
let undefined1 = (x: Undefined.t<int>) => x

@genType
let dict0 = (x: Js.Dict.t<string>) => x
let dict0 = (x: dict<string>) => x

@genType
let dict1 = (x: Dict.t<string>) => x
let dict1 = (x: dict<string>) => x

@genType
let promise0 = (x: promise<string>) => x
Expand Down
2 changes: 1 addition & 1 deletion tests/gentype_tests/typescript-react-example/src/Dict.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
type t<'a> = Js.Dict.t<'a>
type t<'a> = dict<'a>
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type opaqueVariant =
@gentype
type genTypeMispelled = int

@genType type dictString = Js.Dict.t<string>
@genType type dictString = dict<string>

@genType let jsonStringify = Js.Json.stringify

Expand Down
2 changes: 1 addition & 1 deletion tests/syntax_tests/data/idempotency/bs-css/CssEmotion.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include Css_Legacy_Core.Make({
external injectRaw: (. string) => unit = "injectGlobal"

@module("emotion")
external makeKeyFrames: (. Js.Dict.t<Js.Json.t>) => string = "keyframes"
external makeKeyFrames: (. dict<Js.Json.t>) => string = "keyframes"
})

type cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include Css_Js_Core.Make({
external injectRaw: (. string) => unit = "injectGlobal"

@module("emotion")
external makeKeyFrames: (. Js.Dict.t<Js.Json.t>) => string = "keyframes"
external makeKeyFrames: (. dict<Js.Json.t>) => string = "keyframes"
})

type cache
Expand Down
2 changes: 1 addition & 1 deletion tests/syntax_tests/data/idempotency/bs-css/Css_Core.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module type CssImplementationIntf = {
let injectRule: (. Js.Json.t) => unit
let injectRaw: (. string) => unit
let make: (. Js.Json.t) => string
let makeKeyFrames: (. Js.Dict.t<Js.Json.t>) => string
let makeKeyFrames: (. dict<Js.Json.t>) => string
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module URLSearchParams = {
type t

@new external make: string => t = "URLSearchParams"
@new external makeWithDict: Js.Dict.t<string> => t = "URLSearchParams"
@new external makeWithDict: dict<string> => t = "URLSearchParams"
@new external makeWithArray: array<(string, string)> => t = "URLSearchParams"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Map: {
let set: (t<'key, 'value>, 'key, 'value) => unit
let empty: unit => t<'key, 'value>
} = {
type t<'key, 'value> = Js.Dict.t<'value> constraint 'key = string
type t<'key, 'value> = dict<'value> constraint 'key = string
let keys = Js.Dict.keys
let get = Js.Dict.unsafeGet
let get_opt = Js.Dict.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type locationFragments = {
}

@module("serialize-query-params")
external updateInLocation: (Js.Dict.t<option<encoded>>, Window.location) => locationFragments =
external updateInLocation: (dict<option<encoded>>, Window.location) => locationFragments =
"updateInLocation"

@module("serialize-query-params")
external parse: string => Js.Dict.t<encoded> = "parse"
external parse: string => dict<encoded> = "parse"
6 changes: 3 additions & 3 deletions tests/syntax_tests/data/idempotency/nook-exchange/Item.res
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ let getCanonicalVariant = (~item, ~variant) =>
type variantNames =
| NameOneDimension(array<string>)
| NameTwoDimensions((array<string>, array<string>))
let variantNames: Js.Dict.t<variantNames> = variantsJson |> {
let variantNames: dict<variantNames> = variantsJson |> {
open Json.Decode
dict(
oneOf(list{
Expand All @@ -261,8 +261,8 @@ type translationItem = {
variants: option<variantNames>,
}
type translations = {
items: Js.Dict.t<translationItem>,
materials: Js.Dict.t<string>,
items: dict<translationItem>,
materials: dict<string>,
}
let translations: ref<option<translations>> = ref(None)
let setTranslations = json => {
Expand Down
2 changes: 1 addition & 1 deletion tests/syntax_tests/data/idempotency/nook-exchange/User.res
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type t = {
id: string,
username: string,
email: option<string>,
items: Js.Dict.t<item>,
items: dict<item>,
profileText: string,
enableCatalogCheckbox: bool,
followeeIds: option<array<string>>,
Expand Down
6 changes: 3 additions & 3 deletions tests/syntax_tests/data/idempotency/nook-exchange/Utils.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@val @scope("Object")
external objectAssign: (Js.Dict.t<'a>, Js.Dict.t<'a>) => unit = "assign"
external objectAssign: (dict<'a>, dict<'a>) => unit = "assign"

@val @scope("Object") @variadic
external objectAssignMany: array<Js.Dict.t<'a>> => unit = "assign"
external objectAssignMany: array<dict<'a>> => unit = "assign"

let cloneJsDict = dict => {
let clone = Js.Dict.empty()
Expand All @@ -20,7 +20,7 @@ type any
let _internalDeleteJsDictKey: (any, string) => unit = %raw(
"function(dict, key) { delete dict[key]; }"
)
external convertToAny: Js.Dict.t<'a> => any = "%identity"
external convertToAny: dict<'a> => any = "%identity"

let deleteJsDictKey = (dict, key) => _internalDeleteJsDictKey(convertToAny(dict), key)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type getInitialPropsFn<'a> = {"query": Js.Dict.t<string>, "req": Js.Nullable.t<'a>} => Js.Promise.t<
type getInitialPropsFn<'a> = {"query": dict<string>, "req": Js.Nullable.t<'a>} => Js.Promise.t<
'a,
>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Link = Next.Link

// Structure defined by `scripts/extract-indices.js`
let indexData: Js.Dict.t<{
let indexData: dict<{
"moduleName": string,
"headers": array<{
"name": string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Link = Next.Link

// Structure defined by `scripts/extract-tocs.js`
let tocData: Js.Dict.t<{
let tocData: dict<{
"title": string,
"headers": array<{
"name": string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hljs.registerLanguage('json', jsonHighlightJs);
module Link = Next.Link

// Structure defined by `scripts/extract-tocs.js`
let tocData: Js.Dict.t<{
let tocData: dict<{
"title": string,
"headers": array<{
"name": string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Link = Next.Link

// Structure defined by `scripts/extract-indices.js`
let indexData: Js.Dict.t<{
let indexData: dict<{
"moduleName": string,
"headers": array<{
"name": string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Link = Next.Link

// Structure defined by `scripts/extract-tocs.js`
let tocData: Js.Dict.t<{
let tocData: dict<{
"title": string,
"headers": array<{
"name": string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Link = Next.Link

// Structure defined by `scripts/extract-tocs.js`
let tocData: Js.Dict.t<{
let tocData: dict<{
"title": string,
"headers": array<{
"name": string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Link = Next.Link

// Structure defined by `scripts/extract-tocs.js`
let tocData: Js.Dict.t<{
let tocData: dict<{
"title": string,
"headers": array<{
"name": string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open Globals
type threeBoxImageData = {
@as("@type")
imageType: string,
contentUrl: Js.Dict.t<string>,
contentUrl: dict<string>,
}
type threeBoxImage = array<threeBoxImageData>
type threeBoxTwitterVerification = {
Expand All @@ -32,7 +32,7 @@ type threeBoxUserInfo = {
type userVerification = {threeBox: threeBoxUserInfo}

type userInfo = {
userInfo: Js.Dict.t<userVerification>,
userInfo: dict<userVerification>,
update: (string, bool) => unit,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type t = @attrBeforeLblA ((~a: int) => (@attrBeforeLblB ((~b: int) => (@attr fl
type t = @attr ~a: int => unit

type getInitialPropsFn<'a> = {
"query": Js.Dict.t<string>,
"query": dict<string>,
"req": Js.Nullable.t<Js.t<'a>>,
} => Js.Promise.t<Js.t<'a>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ type nonrec t =
[ `Has_arity1 ]) function$)[@attrBeforeLblA ])
type nonrec t = ((a:((int)[@res.namedArgLoc ]) -> unit)[@attr ])
type nonrec 'a getInitialPropsFn =
(< query: string Js.Dict.t ;req: 'a Js.t Js.Nullable.t > ->
(< query: string dict ;req: 'a Js.t Js.Nullable.t > ->
'a Js.t Js.Promise.t,
[ `Has_arity1 ]) function$
2 changes: 1 addition & 1 deletion tests/syntax_tests/data/printer/typexpr/arrow.res
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type arrows = (int, (float => unit) => unit, float) => unit
let prepare_expansion: ((type_expr, type_expr)) => (type_expr, type_expr) = f

type getInitialPropsFn<'a> = {
"query": Js.Dict.t<string>,
"query": dict<string>,
"req": Js.Nullable.t<Js.t<'a>>,
} => Js.Promise.t<Js.t<'a>>

Expand Down
Loading

0 comments on commit 3b7410f

Please sign in to comment.