Fix fontWeight binding (make it an abstract type) (#776) · rescript-react-native/rescript-react-native@44885db

3 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -13,7 +13,10 @@ function rad(num) {

1313

return num.toString() + "rad";

1414

}

1515
16+

var FontWeight = {};

17+
1618

exports.pct = pct;

1719

exports.deg = deg;

1820

exports.rad = rad;

21+

exports.FontWeight = FontWeight;

1922

/* No side effect */

Original file line numberDiff line numberDiff line change

@@ -51,19 +51,36 @@ type resizeMode = [#cover | #contain | #stretch | #repeat | #center]

5151
5252

type fontStyle = [#normal | #italic]

5353
54-

type fontWeight = [

55-

| #normal

56-

| #bold

57-

| #100

58-

| #200

59-

| #300

60-

| #400

61-

| #500

62-

| #600

63-

| #700

64-

| #800

65-

| #900

66-

]

54+

module FontWeight = {

55+

// Note: we cannot model this as a polymorphic variant

56+

// because #"100" = #100 = the number 100 in JS, but we need the string "100" here.

57+

type t = string

58+
59+

@inline

60+

let normal = "normal"

61+

@inline

62+

let bold = "bold"

63+

@inline

64+

let _100 = "100"

65+

@inline

66+

let _200 = "200"

67+

@inline

68+

let _300 = "300"

69+

@inline

70+

let _400 = "400"

71+

@inline

72+

let _500 = "500"

73+

@inline

74+

let _600 = "600"

75+

@inline

76+

let _700 = "700"

77+

@inline

78+

let _800 = "800"

79+

@inline

80+

let _900 = "900"

81+

}

82+
83+

type fontWeight = FontWeight.t

6784
6885

type fontVariant = [

6986

| #"small-caps"

Original file line numberDiff line numberDiff line change

@@ -48,19 +48,36 @@ type resizeMode = [#cover | #contain | #stretch | #repeat | #center]

4848
4949

type fontStyle = [#normal | #italic]

5050
51-

type fontWeight = [

52-

| #normal

53-

| #bold

54-

| #100

55-

| #200

56-

| #300

57-

| #400

58-

| #500

59-

| #600

60-

| #700

61-

| #800

62-

| #900

63-

]

51+

module FontWeight: {

52+

// Note: we cannot model this as a polymorphic variant

53+

// because #"100" = #100 = the number 100 in JS, but we need the string "100" here.

54+

type t

55+
56+

@inline("normal")

57+

let normal: t

58+

@inline("bold")

59+

let bold: t

60+

@inline("100")

61+

let _100: t

62+

@inline("200")

63+

let _200: t

64+

@inline("300")

65+

let _300: t

66+

@inline("400")

67+

let _400: t

68+

@inline("500")

69+

let _500: t

70+

@inline("600")

71+

let _600: t

72+

@inline("700")

73+

let _700: t

74+

@inline("800")

75+

let _800: t

76+

@inline("900")

77+

let _900: t

78+

}

79+
80+

type fontWeight = FontWeight.t

6481
6582

type fontVariant = [

6683

| #"small-caps"