From e9d3937f046b4cf268ddeb4f1eecb694bc79d5ca Mon Sep 17 00:00:00 2001 From: cannorin Date: Thu, 26 May 2022 15:40:38 +0900 Subject: [PATCH] Rebase to v2 --- src/Targets/ReScript/ReScriptHelper.fs | 2 +- src/Targets/ReScript/Writer.fs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Targets/ReScript/ReScriptHelper.fs b/src/Targets/ReScript/ReScriptHelper.fs index 0a7c1087..f4408e6b 100644 --- a/src/Targets/ReScript/ReScriptHelper.fs +++ b/src/Targets/ReScript/ReScriptHelper.fs @@ -97,7 +97,7 @@ module Attr = module Naming = let removeInvalidChars (s: string) = - s.ToCharArray() + s.Trim('"').ToCharArray() |> Array.map (fun c -> if Char.isAlphabetOrDigit c || c = '_' || c = '\'' then c else '_') |> System.String diff --git a/src/Targets/ReScript/Writer.fs b/src/Targets/ReScript/Writer.fs index 42f5cee8..3cb43f34 100644 --- a/src/Targets/ReScript/Writer.fs +++ b/src/Targets/ReScript/Writer.fs @@ -1556,23 +1556,23 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured let addAnonymousInterfaceExcluding ais current = addAnonymousInterfaceExcludingWithKnownTypes (knownTypes ()) ais current match s with - | Module m -> + | Namespace m -> let module' = - let scope = - if m.isNamespace then Scope.Default - else Scope.Module m.name - let node = {| StructuredTextNode.empty with comments = comments; scope = scope |} + let node = {| StructuredTextNode.empty with comments = comments; scope = Scope.Default |} let module' = current |> getTrie [m.name] |> set node let ctx = ctx |> Context.ofChildNamespace m.name m.statements |> List.fold (folder ctx) module' let current = current |> setTrie [m.name] module' match module'.value with | None -> current - | Some _ -> - let kind = - if m.isNamespace then Kind.OfNamespace - else Kind.OfModule - current |> addExport m.name kind (if m.isNamespace then "namespace" else "module") + | Some _ -> current |> addExport m.name Kind.OfNamespace "namespace" + | AmbientModule m -> + let module' = + let node = {| StructuredTextNode.empty with comments = comments; scope = Scope.Module m.name.unquoted |} + let module' = current |> getTrie [m.name.orig] |> set node + let ctx = ctx |> Context.ofChildNamespace m.name.orig + m.statements |> List.fold (folder ctx) module' + current |> setTrie [m.name.orig] module' | Global m -> current |> inTrie ["global"] (fun g -> let node = {| StructuredTextNode.empty with scope = Scope.Global |}