@alloy-js/csharp 0.21.0-dev.14 → 0.21.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/var/declaration.d.ts +6 -2
- package/dist/src/components/var/declaration.d.ts.map +1 -1
- package/dist/src/components/var/declaration.js +4 -1
- package/dist/src/components/var/declaration.js.map +1 -1
- package/dist/src/components/var/declaration.test.js +19 -2
- package/dist/src/components/var/declaration.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/var/declaration.test.tsx +15 -1
- package/src/components/var/declaration.tsx +12 -3
- package/temp/api.json +85 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/csharp",
|
|
3
|
-
"version": "0.21.0-dev.
|
|
3
|
+
"version": "0.21.0-dev.16",
|
|
4
4
|
"description": "Alloy components for CSharp language.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"./stc": {
|
|
10
10
|
"import": "./dist/src/components/stc/index.js"
|
|
11
11
|
},
|
|
12
|
-
"./global
|
|
13
|
-
"import": "./dist/src/builtins
|
|
12
|
+
"./global/*": {
|
|
13
|
+
"import": "./dist/src/builtins/*/index.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"imports": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { List, namekey, refkey } from "@alloy-js/core";
|
|
2
|
-
import { expect, it } from "vitest";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
3
|
import { TestNamespace } from "../../../test/utils.jsx";
|
|
4
4
|
import { VarDeclaration } from "./declaration.jsx";
|
|
5
5
|
|
|
@@ -66,3 +66,17 @@ it("links namekey", () => {
|
|
|
66
66
|
var testVar2 = testVar;
|
|
67
67
|
`);
|
|
68
68
|
});
|
|
69
|
+
|
|
70
|
+
describe("modifiers", () => {
|
|
71
|
+
it.each(["const", "using"])("%s", (mod) => {
|
|
72
|
+
expect(
|
|
73
|
+
<TestNamespace>
|
|
74
|
+
<VarDeclaration {...{ [mod]: true }} name="test" type="object">
|
|
75
|
+
a
|
|
76
|
+
</VarDeclaration>
|
|
77
|
+
</TestNamespace>,
|
|
78
|
+
).toRenderTo(`
|
|
79
|
+
${mod} object test = a;
|
|
80
|
+
`);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
Namekey,
|
|
8
8
|
Refkey,
|
|
9
9
|
} from "@alloy-js/core";
|
|
10
|
+
import { computeModifiersPrefix, makeModifiers } from "../../modifiers.js";
|
|
10
11
|
import { createVariableSymbol } from "../../symbols/factories.js";
|
|
11
12
|
|
|
12
13
|
/** Props for {@link VarDeclaration} component */
|
|
13
14
|
export interface VarDeclarationProps
|
|
14
|
-
extends Omit<DeclarationProps, "nameKind"
|
|
15
|
+
extends Omit<DeclarationProps, "nameKind">,
|
|
16
|
+
VarModifiers {
|
|
15
17
|
/** Variable name */
|
|
16
18
|
name: string | Namekey;
|
|
17
19
|
/** Type of the variable declaration. If not specified, defaults to "var" */
|
|
@@ -20,11 +22,18 @@ export interface VarDeclarationProps
|
|
|
20
22
|
refkey?: Refkey;
|
|
21
23
|
/** Variable value */
|
|
22
24
|
children?: Children;
|
|
25
|
+
}
|
|
23
26
|
|
|
27
|
+
export interface VarModifiers {
|
|
24
28
|
/** Constant variable. Add the const modifier. */
|
|
25
|
-
const?: boolean;
|
|
29
|
+
readonly const?: boolean;
|
|
30
|
+
|
|
31
|
+
/** Disposable variable. Add the using modifier. */
|
|
32
|
+
readonly using?: boolean;
|
|
26
33
|
}
|
|
27
34
|
|
|
35
|
+
const getModifiers = makeModifiers<VarModifiers>(["const", "using"]);
|
|
36
|
+
|
|
28
37
|
/**
|
|
29
38
|
* Render a variable declaration
|
|
30
39
|
*
|
|
@@ -60,7 +69,7 @@ export function VarDeclaration(props: VarDeclarationProps) {
|
|
|
60
69
|
}
|
|
61
70
|
return (
|
|
62
71
|
<Declaration symbol={sym}>
|
|
63
|
-
{props
|
|
72
|
+
{computeModifiersPrefix([getModifiers(props)])}
|
|
64
73
|
<TypeSlot>{props.type ?? "var"}</TypeSlot> <Name /> ={" "}
|
|
65
74
|
<ValueSlot>{props.children}</ValueSlot>;
|
|
66
75
|
</Declaration>
|
package/temp/api.json
CHANGED
|
@@ -16856,6 +16856,15 @@
|
|
|
16856
16856
|
"kind": "Content",
|
|
16857
16857
|
"text": ", \"nameKind\">"
|
|
16858
16858
|
},
|
|
16859
|
+
{
|
|
16860
|
+
"kind": "Content",
|
|
16861
|
+
"text": ", "
|
|
16862
|
+
},
|
|
16863
|
+
{
|
|
16864
|
+
"kind": "Reference",
|
|
16865
|
+
"text": "VarModifiers",
|
|
16866
|
+
"canonicalReference": "@alloy-js/csharp!VarModifiers:interface"
|
|
16867
|
+
},
|
|
16859
16868
|
{
|
|
16860
16869
|
"kind": "Content",
|
|
16861
16870
|
"text": " "
|
|
@@ -16894,33 +16903,6 @@
|
|
|
16894
16903
|
"endIndex": 2
|
|
16895
16904
|
}
|
|
16896
16905
|
},
|
|
16897
|
-
{
|
|
16898
|
-
"kind": "PropertySignature",
|
|
16899
|
-
"canonicalReference": "@alloy-js/csharp!VarDeclarationProps#const:member",
|
|
16900
|
-
"docComment": "/**\n * Constant variable. Add the const modifier.\n */\n",
|
|
16901
|
-
"excerptTokens": [
|
|
16902
|
-
{
|
|
16903
|
-
"kind": "Content",
|
|
16904
|
-
"text": "const?: "
|
|
16905
|
-
},
|
|
16906
|
-
{
|
|
16907
|
-
"kind": "Content",
|
|
16908
|
-
"text": "boolean"
|
|
16909
|
-
},
|
|
16910
|
-
{
|
|
16911
|
-
"kind": "Content",
|
|
16912
|
-
"text": ";"
|
|
16913
|
-
}
|
|
16914
|
-
],
|
|
16915
|
-
"isReadonly": false,
|
|
16916
|
-
"isOptional": true,
|
|
16917
|
-
"releaseTag": "Public",
|
|
16918
|
-
"name": "const",
|
|
16919
|
-
"propertyTypeTokenRange": {
|
|
16920
|
-
"startIndex": 1,
|
|
16921
|
-
"endIndex": 2
|
|
16922
|
-
}
|
|
16923
|
-
},
|
|
16924
16906
|
{
|
|
16925
16907
|
"kind": "PropertySignature",
|
|
16926
16908
|
"canonicalReference": "@alloy-js/csharp!VarDeclarationProps#name:member",
|
|
@@ -17014,8 +16996,84 @@
|
|
|
17014
16996
|
{
|
|
17015
16997
|
"startIndex": 1,
|
|
17016
16998
|
"endIndex": 5
|
|
16999
|
+
},
|
|
17000
|
+
{
|
|
17001
|
+
"startIndex": 6,
|
|
17002
|
+
"endIndex": 7
|
|
17017
17003
|
}
|
|
17018
17004
|
]
|
|
17005
|
+
},
|
|
17006
|
+
{
|
|
17007
|
+
"kind": "Interface",
|
|
17008
|
+
"canonicalReference": "@alloy-js/csharp!VarModifiers:interface",
|
|
17009
|
+
"docComment": "",
|
|
17010
|
+
"excerptTokens": [
|
|
17011
|
+
{
|
|
17012
|
+
"kind": "Content",
|
|
17013
|
+
"text": "export interface VarModifiers "
|
|
17014
|
+
}
|
|
17015
|
+
],
|
|
17016
|
+
"fileUrlPath": "src/components/var/declaration.tsx",
|
|
17017
|
+
"releaseTag": "Public",
|
|
17018
|
+
"name": "VarModifiers",
|
|
17019
|
+
"preserveMemberOrder": false,
|
|
17020
|
+
"members": [
|
|
17021
|
+
{
|
|
17022
|
+
"kind": "PropertySignature",
|
|
17023
|
+
"canonicalReference": "@alloy-js/csharp!VarModifiers#const:member",
|
|
17024
|
+
"docComment": "/**\n * Constant variable. Add the const modifier.\n */\n",
|
|
17025
|
+
"excerptTokens": [
|
|
17026
|
+
{
|
|
17027
|
+
"kind": "Content",
|
|
17028
|
+
"text": "readonly const?: "
|
|
17029
|
+
},
|
|
17030
|
+
{
|
|
17031
|
+
"kind": "Content",
|
|
17032
|
+
"text": "boolean"
|
|
17033
|
+
},
|
|
17034
|
+
{
|
|
17035
|
+
"kind": "Content",
|
|
17036
|
+
"text": ";"
|
|
17037
|
+
}
|
|
17038
|
+
],
|
|
17039
|
+
"isReadonly": true,
|
|
17040
|
+
"isOptional": true,
|
|
17041
|
+
"releaseTag": "Public",
|
|
17042
|
+
"name": "const",
|
|
17043
|
+
"propertyTypeTokenRange": {
|
|
17044
|
+
"startIndex": 1,
|
|
17045
|
+
"endIndex": 2
|
|
17046
|
+
}
|
|
17047
|
+
},
|
|
17048
|
+
{
|
|
17049
|
+
"kind": "PropertySignature",
|
|
17050
|
+
"canonicalReference": "@alloy-js/csharp!VarModifiers#using:member",
|
|
17051
|
+
"docComment": "/**\n * Disposable variable. Add the using modifier.\n */\n",
|
|
17052
|
+
"excerptTokens": [
|
|
17053
|
+
{
|
|
17054
|
+
"kind": "Content",
|
|
17055
|
+
"text": "readonly using?: "
|
|
17056
|
+
},
|
|
17057
|
+
{
|
|
17058
|
+
"kind": "Content",
|
|
17059
|
+
"text": "boolean"
|
|
17060
|
+
},
|
|
17061
|
+
{
|
|
17062
|
+
"kind": "Content",
|
|
17063
|
+
"text": ";"
|
|
17064
|
+
}
|
|
17065
|
+
],
|
|
17066
|
+
"isReadonly": true,
|
|
17067
|
+
"isOptional": true,
|
|
17068
|
+
"releaseTag": "Public",
|
|
17069
|
+
"name": "using",
|
|
17070
|
+
"propertyTypeTokenRange": {
|
|
17071
|
+
"startIndex": 1,
|
|
17072
|
+
"endIndex": 2
|
|
17073
|
+
}
|
|
17074
|
+
}
|
|
17075
|
+
],
|
|
17076
|
+
"extendsTokenRanges": []
|
|
17019
17077
|
}
|
|
17020
17078
|
]
|
|
17021
17079
|
}
|