Skip to content

Commit 9aeb344

Browse files
committed
feat: change exportAssignment to use ImportDefault
[converter][web]
1 parent cd1e14c commit 9aeb344

File tree

7 files changed

+15
-4
lines changed

7 files changed

+15
-4
lines changed

src/Glutinum.Converter/FsharpAST.fs

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ type FSharpAttribute =
179179
/// Generates <c>[&lt;ImportAll(moduleName)&gt;]</c> attribute.
180180
/// </summary>
181181
| ImportAll of moduleName: string
182+
/// <summary>
183+
/// Generates <c>[&lt;ImportDefault(moduleName)&gt;]</c> attribute.
184+
/// </summary>
185+
| ImportDefault of moduleName: string
182186
| Erase
183187
| AllowNullLiteral
184188
| Obsolete of string option

src/Glutinum.Converter/Printer.fs

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ let private attributeToText (fsharpAttribute: FSharpAttribute) =
103103
| FSharpAttribute.EmitMacroConstructor className ->
104104
$"[<Emit(\"new $0.{className}($1...)\")>]"
105105
| FSharpAttribute.ImportAll module_ -> $"[<ImportAll(\"{module_}\")>]"
106+
| FSharpAttribute.ImportDefault module_ ->
107+
$"[<ImportDefault(\"{module_}\")>]"
106108
| FSharpAttribute.EmitIndexer -> "[<EmitIndexer>]"
107109
| FSharpAttribute.Global -> "[<Global>]"
108110
| FSharpAttribute.ParamObject -> "[<ParamObject>]"

src/Glutinum.Converter/Transform.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ let private transformExports
477477
sanitizeNameAndPushScope glueType.Name context
478478

479479
{
480-
Attributes = [ FSharpAttribute.ImportAll "module" ]
480+
Attributes = [ FSharpAttribute.ImportDefault "module" ]
481481
Name = name
482482
OriginalName = glueType.Name
483483
Parameters = []

src/Glutinum.Web/Pages/Editors.FSharpAST.FSharpASTViewer.fs

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ type FSharpASTViewer =
4747
ASTViewer.renderKeyValue "From" from
4848
]
4949

50+
| FSharpAttribute.ImportDefault from ->
51+
ASTViewer.renderNode "ImportDefault" [
52+
ASTViewer.renderKeyValue "From" from
53+
]
54+
5055
| FSharpAttribute.Erase -> ASTViewer.renderValueOnly "Erase"
5156

5257
| FSharpAttribute.AllowNullLiteral ->

tests/specs/references/exportAssignment/default/direct/class.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ open System
66

77
[<Erase>]
88
type Exports =
9-
[<ImportAll("module")>]
9+
[<ImportDefault("module")>]
1010
static member inline ChalkInstance: ChalkInstance = nativeOnly
1111

1212
[<AllowNullLiteral>]

tests/specs/references/exportAssignment/default/intermediateVariable/class.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ open System
66

77
[<Erase>]
88
type Exports =
9-
[<ImportAll("module")>]
9+
[<ImportDefault("module")>]
1010
static member inline chalk: ChalkInstance = nativeOnly
1111

1212

tests/specs/references/exportAssignment/default/intermediateVariable/primitive.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ open System
66

77
[<Erase>]
88
type Exports =
9-
[<ImportAll("module")>]
9+
[<ImportDefault("module")>]
1010
static member inline version: string = nativeOnly
1111

1212
(***)

0 commit comments

Comments
 (0)