Skip to content

Commit d2f0da9

Browse files
committed
Rebase to main
1 parent 759108b commit d2f0da9

File tree

4 files changed

+45
-35
lines changed

4 files changed

+45
-35
lines changed

build/build.fs

+11-13
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,25 @@ let setup () =
7777

7878
Target.create "Test" ignore
7979

80-
"Clean" ?=> "Build"
80+
Target.create "Publish" ignore
8181

82-
"Clean"
83-
?=> "YarnInstall"
82+
"YarnInstall"
8483
==> "Restore"
8584
==> "Prepare"
86-
?=> "Build"
8785

8886
"Prepare"
89-
?=> "BuildForTest"
90-
?=> "BuildForPublish"
87+
==> "BuildForTest"
9188
==> "Build"
9289

9390
"Prepare"
94-
?=> "Watch"
91+
==> "BuildForPublish"
92+
93+
"Prepare"
94+
==> "Watch"
95+
96+
"Clean"
97+
?=> "BuildForTest" ?=> "Build" ?=> "Test"
98+
?=> "BuildForPublish" ?=> "Publish"
9599

96100
// Test targets
97101

@@ -270,8 +274,6 @@ module Publish =
270274
inDirectory targetDir <| fun () -> dune "build"
271275

272276
let setup () =
273-
Target.create "Publish" <| fun _ -> ()
274-
275277
Target.create "PublishNpm" <| fun _ ->
276278
Npm.updateVersion ()
277279

@@ -285,10 +287,6 @@ module Publish =
285287
==> "PublishJsoo"
286288
==> "Publish"
287289

288-
"TestJsoo" ==> "PublishJsoo"
289-
290-
"Build" ?=> "Test" ?=> "Publish"
291-
292290
// Utility targets
293291

294292
module Utility =

src/Targets/ReScript/Writer.fs

+17-6
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ let emitTypeAliasesImpl
897897
(baseName: string)
898898
flags overrideFunc
899899
(ctx: Context)
900+
loc
900901
(typrms: TypeParam list)
901902
(target: text option)
902903
(lines: {| name: string; tyargs:(TypeParam * text) list; target: text option; isOverload: bool |} -> 'a list) =
@@ -911,16 +912,26 @@ let emitTypeAliasesImpl
911912
let name = Naming.createTypeNameOfArity arity None baseName
912913
let tyargs' = List.take arity tyargs
913914
let typrms' = List.take arity typrms
915+
916+
let bindings =
917+
createBindings (ctx.currentNamespace @ [name]) loc
918+
(typrms |> List.skip arity)
919+
(typrms |> List.skip arity |> List.map (fun t ->
920+
match t.defaultType with
921+
| None -> impossible "emitTypeAliases"
922+
| Some t -> t
923+
))
924+
914925
let target =
915926
Type.appOpt
916927
(str baseName)
917928
[
918929
for tyarg in tyargs' do yield tyarg
919930
for t in typrms |> List.skip arity do
920-
match t.defaultType with
921-
| None -> impossible "emitTypeAliases"
922-
| Some t -> yield emitType_ ctx t
931+
let t' = repeatUntilEquilibrium (substTypeVar bindings ctx) (TypeVar t.name)
932+
yield emitType_ ctx t'
923933
]
934+
924935
yield! lines {| name = name; tyargs = List.zip typrms' tyargs'; target = Some target; isOverload = true |}
925936
]
926937

@@ -1084,7 +1095,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c
10841095
if useTags && innerCtx.options.inheritWithTags.HasProvide then
10851096
let alias =
10861097
emitTypeAliasesImpl
1087-
"tags" flags overrideFunc innerCtx c.typeParams (Some emittedLabels)
1098+
"tags" flags overrideFunc innerCtx c.loc c.typeParams (Some emittedLabels)
10881099
(fun x -> [Statement.typeAlias false x.name (x.tyargs |> List.map snd) x.target])
10891100
|> concat newline
10901101
alias |> TypeAliasText |> Some
@@ -1129,7 +1140,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c
11291140
| ClassKind.ExportDefaultClass x -> getSelfTyText x.orig
11301141
| ClassKind.AnonymousInterface _ -> fallback
11311142

1132-
emitTypeAliasesImpl "t" flags overrideFunc innerCtx c.typeParams selfTyText.ty (fun x ->
1143+
emitTypeAliasesImpl "t" flags overrideFunc innerCtx c.loc c.typeParams selfTyText.ty (fun x ->
11331144
if not x.isOverload then
11341145
[TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = selfTyText.isRec; shouldAssert = false |}]
11351146
else
@@ -1569,7 +1580,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured
15691580
let isRec =
15701581
knownTypes |> Set.contains (KnownType.Ident (ctx |> Context.getFullNameOfCurrentNamespace))
15711582
let items =
1572-
emitTypeAliasesImpl "t" emitTypeFlags OverrideFunc.noOverride ctx ta.typeParams (emitSelfType ctx ta.target |> Some) (fun x ->
1583+
emitTypeAliasesImpl "t" emitTypeFlags OverrideFunc.noOverride ctx ta.loc ta.typeParams (emitSelfType ctx ta.target |> Some) (fun x ->
15731584
if not x.isOverload then
15741585
[TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = false; shouldAssert = false |}]
15751586
else
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type t<'k, 'v>

test/res/yarn.lock

+16-16
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ chalk@^5.0.1:
6565
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6"
6666
integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==
6767

68-
cliui@^7.0.2:
69-
version "7.0.4"
70-
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
71-
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
68+
cliui@^8.0.1:
69+
version "8.0.1"
70+
resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"
71+
integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==
7272
dependencies:
7373
string-width "^4.2.0"
74-
strip-ansi "^6.0.0"
74+
strip-ansi "^6.0.1"
7575
wrap-ansi "^7.0.0"
7676

7777
color-convert@^1.9.0:
@@ -166,10 +166,10 @@ supports-color@^5.3.0:
166166
dependencies:
167167
has-flag "^3.0.0"
168168

169-
typescript@4.7:
170-
version "4.7.4"
171-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
172-
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
169+
typescript@^5.1.6:
170+
version "5.1.6"
171+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
172+
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
173173

174174
wrap-ansi@^7.0.0:
175175
version "7.0.0"
@@ -185,20 +185,20 @@ y18n@^5.0.5:
185185
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
186186
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
187187

188-
yargs-parser@^21.0.0:
188+
yargs-parser@^21.1.1:
189189
version "21.1.1"
190190
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
191191
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
192192

193-
194-
version "17.5.1"
195-
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e"
196-
integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==
193+
yargs@^17.5.1:
194+
version "17.7.2"
195+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
196+
integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==
197197
dependencies:
198-
cliui "^7.0.2"
198+
cliui "^8.0.1"
199199
escalade "^3.1.1"
200200
get-caller-file "^2.0.5"
201201
require-directory "^2.1.1"
202202
string-width "^4.2.3"
203203
y18n "^5.0.5"
204-
yargs-parser "^21.0.0"
204+
yargs-parser "^21.1.1"

0 commit comments

Comments
 (0)