Skip to content

Commit

Permalink
Rebase to main
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin committed Jul 17, 2023
1 parent 759108b commit d2f0da9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 35 deletions.
24 changes: 11 additions & 13 deletions build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,25 @@ let setup () =

Target.create "Test" ignore

"Clean" ?=> "Build"
Target.create "Publish" ignore

"Clean"
?=> "YarnInstall"
"YarnInstall"
==> "Restore"
==> "Prepare"
?=> "Build"

"Prepare"
?=> "BuildForTest"
?=> "BuildForPublish"
==> "BuildForTest"
==> "Build"

"Prepare"
?=> "Watch"
==> "BuildForPublish"

"Prepare"
==> "Watch"

"Clean"
?=> "BuildForTest" ?=> "Build" ?=> "Test"
?=> "BuildForPublish" ?=> "Publish"

// Test targets

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

let setup () =
Target.create "Publish" <| fun _ -> ()

Target.create "PublishNpm" <| fun _ ->
Npm.updateVersion ()

Expand All @@ -285,10 +287,6 @@ module Publish =
==> "PublishJsoo"
==> "Publish"

"TestJsoo" ==> "PublishJsoo"

"Build" ?=> "Test" ?=> "Publish"

// Utility targets

module Utility =
Expand Down
23 changes: 17 additions & 6 deletions src/Targets/ReScript/Writer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ let emitTypeAliasesImpl
(baseName: string)
flags overrideFunc
(ctx: Context)
loc
(typrms: TypeParam list)
(target: text option)
(lines: {| name: string; tyargs:(TypeParam * text) list; target: text option; isOverload: bool |} -> 'a list) =
Expand All @@ -911,16 +912,26 @@ let emitTypeAliasesImpl
let name = Naming.createTypeNameOfArity arity None baseName
let tyargs' = List.take arity tyargs
let typrms' = List.take arity typrms

let bindings =
createBindings (ctx.currentNamespace @ [name]) loc
(typrms |> List.skip arity)
(typrms |> List.skip arity |> List.map (fun t ->
match t.defaultType with
| None -> impossible "emitTypeAliases"
| Some t -> t
))

let target =
Type.appOpt
(str baseName)
[
for tyarg in tyargs' do yield tyarg
for t in typrms |> List.skip arity do
match t.defaultType with
| None -> impossible "emitTypeAliases"
| Some t -> yield emitType_ ctx t
let t' = repeatUntilEquilibrium (substTypeVar bindings ctx) (TypeVar t.name)
yield emitType_ ctx t'
]

yield! lines {| name = name; tyargs = List.zip typrms' tyargs'; target = Some target; isOverload = true |}
]

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

emitTypeAliasesImpl "t" flags overrideFunc innerCtx c.typeParams selfTyText.ty (fun x ->
emitTypeAliasesImpl "t" flags overrideFunc innerCtx c.loc c.typeParams selfTyText.ty (fun x ->
if not x.isOverload then
[TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = selfTyText.isRec; shouldAssert = false |}]
else
Expand Down Expand Up @@ -1569,7 +1580,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured
let isRec =
knownTypes |> Set.contains (KnownType.Ident (ctx |> Context.getFullNameOfCurrentNamespace))
let items =
emitTypeAliasesImpl "t" emitTypeFlags OverrideFunc.noOverride ctx ta.typeParams (emitSelfType ctx ta.target |> Some) (fun x ->
emitTypeAliasesImpl "t" emitTypeFlags OverrideFunc.noOverride ctx ta.loc ta.typeParams (emitSelfType ctx ta.target |> Some) (fun x ->
if not x.isOverload then
[TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = false; shouldAssert = false |}]
else
Expand Down
1 change: 1 addition & 0 deletions test/res/src/placeholders/ReadonlyMap.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type t<'k, 'v>
32 changes: 16 additions & 16 deletions test/res/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ chalk@^5.0.1:
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6"
integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==

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

color-convert@^1.9.0:
Expand Down Expand Up @@ -166,10 +166,10 @@ supports-color@^5.3.0:
dependencies:
has-flag "^3.0.0"

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

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

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

[email protected]:
version "17.5.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e"
integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==
yargs@^17.5.1:
version "17.7.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==
dependencies:
cliui "^7.0.2"
cliui "^8.0.1"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.3"
y18n "^5.0.5"
yargs-parser "^21.0.0"
yargs-parser "^21.1.1"

0 comments on commit d2f0da9

Please sign in to comment.