@typespec/emitter-framework 0.6.0-dev.2 → 0.6.0-dev.4
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/typescript/components/arrow-function.d.ts +17 -0
- package/dist/src/typescript/components/arrow-function.d.ts.map +1 -0
- package/dist/src/typescript/components/arrow-function.js +31 -0
- package/dist/src/typescript/components/arrow-function.js.map +1 -0
- package/dist/src/typescript/components/function-declaration.d.ts +5 -0
- package/dist/src/typescript/components/function-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/function-declaration.js +5 -1
- package/dist/src/typescript/components/function-declaration.js.map +1 -1
- package/dist/src/typescript/components/function-expression.d.ts +17 -0
- package/dist/src/typescript/components/function-expression.d.ts.map +1 -0
- package/dist/src/typescript/components/function-expression.js +31 -0
- package/dist/src/typescript/components/function-expression.js.map +1 -0
- package/dist/src/typescript/components/function-type.d.ts +17 -0
- package/dist/src/typescript/components/function-type.d.ts.map +1 -0
- package/dist/src/typescript/components/function-type.js +31 -0
- package/dist/src/typescript/components/function-type.js.map +1 -0
- package/dist/src/typescript/components/index.d.ts +6 -0
- package/dist/src/typescript/components/index.d.ts.map +1 -1
- package/dist/src/typescript/components/index.js +6 -0
- package/dist/src/typescript/components/index.js.map +1 -1
- package/dist/src/typescript/components/interface-member.d.ts +1 -2
- package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-member.js +3 -19
- package/dist/src/typescript/components/interface-member.js.map +1 -1
- package/dist/src/typescript/components/interface-method.d.ts +15 -0
- package/dist/src/typescript/components/interface-method.d.ts.map +1 -0
- package/dist/src/typescript/components/interface-method.js +34 -0
- package/dist/src/typescript/components/interface-method.js.map +1 -0
- package/dist/src/typescript/components/type-alias-declaration.d.ts +6 -2
- package/dist/src/typescript/components/type-alias-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-alias-declaration.js +7 -2
- package/dist/src/typescript/components/type-alias-declaration.js.map +1 -1
- package/dist/src/typescript/components/type-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-declaration.js +4 -0
- package/dist/src/typescript/components/type-declaration.js.map +1 -1
- package/dist/src/typescript/components/type-expression.d.ts +6 -0
- package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-expression.js +6 -1
- package/dist/src/typescript/components/type-expression.js.map +1 -1
- package/dist/test/typescript/components/arrow-function.test.d.ts +2 -0
- package/dist/test/typescript/components/arrow-function.test.d.ts.map +1 -0
- package/dist/test/typescript/components/function-expression.test.d.ts +2 -0
- package/dist/test/typescript/components/function-expression.test.d.ts.map +1 -0
- package/dist/test/typescript/components/function-type.test.d.ts +2 -0
- package/dist/test/typescript/components/function-type.test.d.ts.map +1 -0
- package/dist/test/typescript/components/interface-method.test.d.ts +2 -0
- package/dist/test/typescript/components/interface-method.test.d.ts.map +1 -0
- package/dist/test/utils.d.ts +3 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/typescript/components/arrow-function.tsx +39 -0
- package/src/typescript/components/function-declaration.tsx +5 -2
- package/src/typescript/components/function-expression.tsx +41 -0
- package/src/typescript/components/function-type.tsx +38 -0
- package/src/typescript/components/index.ts +6 -0
- package/src/typescript/components/interface-member.tsx +2 -19
- package/src/typescript/components/interface-method.tsx +50 -0
- package/src/typescript/components/type-alias-declaration.tsx +10 -4
- package/src/typescript/components/type-declaration.tsx +2 -0
- package/src/typescript/components/type-expression.tsx +11 -2
- package/test/typescript/components/arrow-function.test.tsx +85 -0
- package/test/typescript/components/function-expression.test.tsx +85 -0
- package/test/typescript/components/function-type.test.tsx +80 -0
- package/test/typescript/components/interface-declaration.test.tsx +6 -6
- package/test/typescript/components/interface-method.test.tsx +69 -0
- package/test/typescript/components/type-alias-declaration.test.tsx +20 -2
- package/test/utils.ts +8 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as ts from "@alloy-js/typescript";
|
|
2
|
+
import { Operation } from "@typespec/compiler";
|
|
3
|
+
export interface ArrowFunctionProps extends ts.ArrowFunctionProps {
|
|
4
|
+
type?: Operation;
|
|
5
|
+
/**
|
|
6
|
+
* Where the parameters from passed to the `parameters` prop should be placed
|
|
7
|
+
* relative the ones created from the T`ypeSpec operation.
|
|
8
|
+
*/
|
|
9
|
+
parametersMode?: "prepend" | "append" | "replace";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A TypeScript arrow function. Pass the `type` prop to create the arrow
|
|
13
|
+
* function by converting from a TypeSpec Operation. Any other props provided
|
|
14
|
+
* will take precedence.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ArrowFunction(props: Readonly<ArrowFunctionProps>): import("@alloy-js/core/jsx-runtime").Children;
|
|
17
|
+
//# sourceMappingURL=arrow-function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-function.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/arrow-function.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,kBAAmB,SAAQ,EAAE,CAAC,kBAAkB;IAC/D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC,iDAkBhE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { splitProps } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import * as ts from "@alloy-js/typescript";
|
|
5
|
+
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
6
|
+
import { TypeExpression } from "./type-expression.js";
|
|
7
|
+
/**
|
|
8
|
+
* A TypeScript arrow function. Pass the `type` prop to create the arrow
|
|
9
|
+
* function by converting from a TypeSpec Operation. Any other props provided
|
|
10
|
+
* will take precedence.
|
|
11
|
+
*/
|
|
12
|
+
export function ArrowFunction(props) {
|
|
13
|
+
const [efProps, updateProps, forwardProps] = splitProps(props, ["type"], ["returnType", "parameters"]);
|
|
14
|
+
if (!efProps.type) {
|
|
15
|
+
return _$createComponent(ts.ArrowFunction, _$mergeProps(forwardProps, updateProps));
|
|
16
|
+
}
|
|
17
|
+
const returnType = props.returnType ?? _$createComponent(TypeExpression, {
|
|
18
|
+
get type() {
|
|
19
|
+
return getReturnType(efProps.type);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const allParameters = buildParameterDescriptors(efProps.type.parameters, {
|
|
23
|
+
params: props.parameters,
|
|
24
|
+
mode: props.parametersMode
|
|
25
|
+
});
|
|
26
|
+
return _$createComponent(ts.ArrowFunction, _$mergeProps(forwardProps, {
|
|
27
|
+
returnType: returnType,
|
|
28
|
+
parameters: allParameters
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=arrow-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-function.js","names":["splitProps","ts","buildParameterDescriptors","getReturnType","TypeExpression","ArrowFunction","props","efProps","updateProps","forwardProps","type","_$createComponent","_$mergeProps","returnType","allParameters","parameters","params","mode","parametersMode"],"sources":["../../../../src/typescript/components/arrow-function.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,UAAU,QAAQ,4BAA4B;AACvD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,yBAAyB,EAAEC,aAAa,QAAQ,uBAAuB;AAChF,SAASC,cAAc;AAWvB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,KAAmC,EAAE;EACjE,MAAM,CAACC,OAAO,EAAEC,WAAW,EAAEC,YAAY,CAAC,GAAGT,UAAU,CACrDM,KAAK,EACL,CAAC,MAAM,CAAC,EACR,CAAC,YAAY,EAAE,YAAY,CAC7B,CAAC;EAED,IAAI,CAACC,OAAO,CAACG,IAAI,EAAE;IACjB,OAAAC,iBAAA,CAAQV,EAAE,CAACI,aAAa,EAAAO,YAAA,CAAKH,YAAY,EAAMD,WAAW;EAC5D;EAEA,MAAMK,UAAU,GAAGP,KAAK,CAACO,UAAU,IAAAF,iBAAA,CAAKP,cAAc;IAAA,IAACM,IAAIA,CAAA;MAAA,OAAEP,aAAa,CAACI,OAAO,CAACG,IAAI,CAAC;IAAA;EAAA,EAAI;EAC5F,MAAMI,aAAa,GAAGZ,yBAAyB,CAACK,OAAO,CAACG,IAAI,CAACK,UAAU,EAAE;IACvEC,MAAM,EAAEV,KAAK,CAACS,UAAU;IACxBE,IAAI,EAAEX,KAAK,CAACY;EACd,CAAC,CAAC;EAEF,OAAAP,iBAAA,CAAQV,EAAE,CAACI,aAAa,EAAAO,YAAA,CAAKH,YAAY;IAAEI,UAAU,EAAEA,UAAU;IAAEE,UAAU,EAAED;EAAa;AAC9F","ignoreList":[]}
|
|
@@ -6,6 +6,11 @@ export interface FunctionDeclarationPropsWithType extends Omit<ts.FunctionDeclar
|
|
|
6
6
|
parametersMode?: "prepend" | "append" | "replace";
|
|
7
7
|
}
|
|
8
8
|
export type FunctionDeclarationProps = FunctionDeclarationPropsWithType | ts.FunctionDeclarationProps;
|
|
9
|
+
/**
|
|
10
|
+
* A TypeScript function declaration. Pass the `type` prop to create the
|
|
11
|
+
* function declaration by converting from a TypeSpec Operation. Any other props
|
|
12
|
+
* provided will take precedence.
|
|
13
|
+
*/
|
|
9
14
|
export declare function FunctionDeclaration(props: FunctionDeclarationProps): import("@alloy-js/core").Children;
|
|
10
15
|
export declare namespace FunctionDeclaration {
|
|
11
16
|
var Parameters: (props: FunctionParametersProps) => import("@alloy-js/core").Children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-declaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAItD,MAAM,WAAW,gCACf,SAAQ,IAAI,CAAC,EAAE,CAAC,wBAAwB,EAAE,MAAM,CAAC;IACjD,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,MAAM,wBAAwB,GAChC,gCAAgC,GAChC,EAAE,CAAC,wBAAwB,CAAC;AAEhC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"function-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-declaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAItD,MAAM,WAAW,gCACf,SAAQ,IAAI,CAAC,EAAE,CAAC,wBAAwB,EAAE,MAAM,CAAC;IACjD,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,MAAM,wBAAwB,GAChC,gCAAgC,GAChC,EAAE,CAAC,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qCAkClE;yBAlCe,mBAAmB;4BA2CyB,uBAAuB;;AAPnF,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,EAAE,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC7F,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,uBAAuB,GAAG,4BAA4B,GAAG,EAAE,CAAC,uBAAuB,CAAC"}
|
|
@@ -4,9 +4,13 @@ import { refkey as getRefkey } from "@alloy-js/core";
|
|
|
4
4
|
import * as ts from "@alloy-js/typescript";
|
|
5
5
|
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
6
6
|
import { TypeExpression } from "./type-expression.js";
|
|
7
|
+
/**
|
|
8
|
+
* A TypeScript function declaration. Pass the `type` prop to create the
|
|
9
|
+
* function declaration by converting from a TypeSpec Operation. Any other props
|
|
10
|
+
* provided will take precedence.
|
|
11
|
+
*/
|
|
7
12
|
export function FunctionDeclaration(props) {
|
|
8
13
|
if (!isTypedFunctionDeclarationProps(props)) {
|
|
9
|
-
if (!props.name) {}
|
|
10
14
|
return _$createComponent(ts.FunctionDeclaration, props);
|
|
11
15
|
}
|
|
12
16
|
const refkey = props.refkey ?? getRefkey(props.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-declaration.js","names":["refkey","getRefkey","ts","buildParameterDescriptors","getReturnType","TypeExpression","FunctionDeclaration","props","isTypedFunctionDeclarationProps","
|
|
1
|
+
{"version":3,"file":"function-declaration.js","names":["refkey","getRefkey","ts","buildParameterDescriptors","getReturnType","TypeExpression","FunctionDeclaration","props","isTypedFunctionDeclarationProps","_$createComponent","type","name","useTSNamePolicy","getName","reservedFunctionKeywords","has","returnType","allParameters","parameters","params","mode","parametersMode","async","default","export","kind","children","Parameters","_$memo","isTypedFunctionParametersProps","parameterDescriptors","Set"],"sources":["../../../../src/typescript/components/function-declaration.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,MAAM,IAAIC,SAAS,QAAQ,gBAAgB;AACpD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,yBAAyB,EAAEC,aAAa,QAAQ,uBAA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K,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,CACR,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as ts from "@alloy-js/typescript";
|
|
2
|
+
import { Operation } from "@typespec/compiler";
|
|
3
|
+
export interface FunctionExpressionProps extends ts.FunctionExpressionProps {
|
|
4
|
+
type?: Operation;
|
|
5
|
+
/**
|
|
6
|
+
* Where the parameters from passed to the `parameters` prop should be placed
|
|
7
|
+
* relative the ones created from the TypeSpec operation.
|
|
8
|
+
*/
|
|
9
|
+
parametersMode?: "prepend" | "append" | "replace";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A TypeScript function expression. Pass the `type` prop to create the
|
|
13
|
+
* function expression by converting from a TypeSpec Operation. Any other props
|
|
14
|
+
* provided will take precedence.
|
|
15
|
+
*/
|
|
16
|
+
export declare function FunctionExpression(props: Readonly<FunctionExpressionProps>): import("@alloy-js/core/jsx-runtime").Children;
|
|
17
|
+
//# sourceMappingURL=function-expression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-expression.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,uBAAwB,SAAQ,EAAE,CAAC,uBAAuB;IACzE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,iDAoB1E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { splitProps } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import * as ts from "@alloy-js/typescript";
|
|
5
|
+
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
6
|
+
import { TypeExpression } from "./type-expression.js";
|
|
7
|
+
/**
|
|
8
|
+
* A TypeScript function expression. Pass the `type` prop to create the
|
|
9
|
+
* function expression by converting from a TypeSpec Operation. Any other props
|
|
10
|
+
* provided will take precedence.
|
|
11
|
+
*/
|
|
12
|
+
export function FunctionExpression(props) {
|
|
13
|
+
const [efProps, updateProps, forwardProps] = splitProps(props, ["type"], ["returnType", "parameters"]);
|
|
14
|
+
if (!efProps.type) {
|
|
15
|
+
return _$createComponent(ts.FunctionExpression, _$mergeProps(forwardProps, updateProps));
|
|
16
|
+
}
|
|
17
|
+
const returnType = props.returnType ?? _$createComponent(TypeExpression, {
|
|
18
|
+
get type() {
|
|
19
|
+
return getReturnType(efProps.type);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const allParameters = buildParameterDescriptors(efProps.type.parameters, {
|
|
23
|
+
params: props.parameters,
|
|
24
|
+
mode: props.parametersMode
|
|
25
|
+
});
|
|
26
|
+
return _$createComponent(ts.FunctionExpression, _$mergeProps(forwardProps, {
|
|
27
|
+
returnType: returnType,
|
|
28
|
+
parameters: allParameters
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=function-expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-expression.js","names":["splitProps","ts","buildParameterDescriptors","getReturnType","TypeExpression","FunctionExpression","props","efProps","updateProps","forwardProps","type","_$createComponent","_$mergeProps","returnType","allParameters","parameters","params","mode","parametersMode"],"sources":["../../../../src/typescript/components/function-expression.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,UAAU,QAAQ,4BAA4B;AACvD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,yBAAyB,EAAEC,aAAa,QAAQ,uBAAuB;AAChF,SAASC,cAAc;AAWvB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAAwC,EAAE;EAC3E,MAAM,CAACC,OAAO,EAAEC,WAAW,EAAEC,YAAY,CAAC,GAAGT,UAAU,CACrDM,KAAK,EACL,CAAC,MAAM,CAAC,EACR,CAAC,YAAY,EAAE,YAAY,CAC7B,CAAC;EAED,IAAI,CAACC,OAAO,CAACG,IAAI,EAAE;IACjB,OAAAC,iBAAA,CAAQV,EAAE,CAACI,kBAAkB,EAAAO,YAAA,CAAKH,YAAY,EAAMD,WAAW;EACjE;EAEA,MAAMK,UAAU,GAAGP,KAAK,CAACO,UAAU,IAAAF,iBAAA,CAAKP,cAAc;IAAA,IAACM,IAAIA,CAAA;MAAA,OAAEP,aAAa,CAACI,OAAO,CAACG,IAAI,CAAC;IAAA;EAAA,EAAI;EAC5F,MAAMI,aAAa,GAAGZ,yBAAyB,CAACK,OAAO,CAACG,IAAI,CAACK,UAAU,EAAE;IACvEC,MAAM,EAAEV,KAAK,CAACS,UAAU;IACxBE,IAAI,EAAEX,KAAK,CAACY;EACd,CAAC,CAAC;EAEF,OAAAP,iBAAA,CACGV,EAAE,CAACI,kBAAkB,EAAAO,YAAA,CAAKH,YAAY;IAAEI,UAAU,EAAEA,UAAU;IAAEE,UAAU,EAAED;EAAa;AAE9F","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as ts from "@alloy-js/typescript";
|
|
2
|
+
import { Operation } from "@typespec/compiler";
|
|
3
|
+
export interface FunctionTypeProps extends ts.FunctionTypeProps {
|
|
4
|
+
type?: Operation;
|
|
5
|
+
/**
|
|
6
|
+
* Where the parameters from passed to the `parameters` prop should be placed
|
|
7
|
+
* relative the ones created from the TypeSpec operation.
|
|
8
|
+
*/
|
|
9
|
+
parametersMode?: "prepend" | "append" | "replace";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A TypeScript function type. Pass the `type` prop to create the function type
|
|
13
|
+
* by converting from a TypeSpec Operation. Any other props provided will take
|
|
14
|
+
* precedence.
|
|
15
|
+
*/
|
|
16
|
+
export declare function FunctionType(props: Readonly<FunctionTypeProps>): import("@alloy-js/core/jsx-runtime").Children;
|
|
17
|
+
//# sourceMappingURL=function-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-type.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-type.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,iBAAkB,SAAQ,EAAE,CAAC,iBAAiB;IAC7D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AACD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,iDAkB9D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { splitProps } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import * as ts from "@alloy-js/typescript";
|
|
5
|
+
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
6
|
+
import { TypeExpression } from "./type-expression.js";
|
|
7
|
+
/**
|
|
8
|
+
* A TypeScript function type. Pass the `type` prop to create the function type
|
|
9
|
+
* by converting from a TypeSpec Operation. Any other props provided will take
|
|
10
|
+
* precedence.
|
|
11
|
+
*/
|
|
12
|
+
export function FunctionType(props) {
|
|
13
|
+
const [efProps, updateProps, forwardProps] = splitProps(props, ["type"], ["returnType", "parameters"]);
|
|
14
|
+
if (!efProps.type) {
|
|
15
|
+
return _$createComponent(ts.FunctionType, _$mergeProps(forwardProps, updateProps));
|
|
16
|
+
}
|
|
17
|
+
const returnType = props.returnType ?? _$createComponent(TypeExpression, {
|
|
18
|
+
get type() {
|
|
19
|
+
return getReturnType(efProps.type);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const allParameters = buildParameterDescriptors(efProps.type.parameters, {
|
|
23
|
+
params: props.parameters,
|
|
24
|
+
mode: props.parametersMode
|
|
25
|
+
});
|
|
26
|
+
return _$createComponent(ts.FunctionType, _$mergeProps(forwardProps, {
|
|
27
|
+
returnType: returnType,
|
|
28
|
+
parameters: allParameters
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=function-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-type.js","names":["splitProps","ts","buildParameterDescriptors","getReturnType","TypeExpression","FunctionType","props","efProps","updateProps","forwardProps","type","_$createComponent","_$mergeProps","returnType","allParameters","parameters","params","mode","parametersMode"],"sources":["../../../../src/typescript/components/function-type.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,UAAU,QAAQ,4BAA4B;AACvD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,yBAAyB,EAAEC,aAAa,QAAQ,uBAAuB;AAChF,SAASC,cAAc;AAUvB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,KAAkC,EAAE;EAC/D,MAAM,CAACC,OAAO,EAAEC,WAAW,EAAEC,YAAY,CAAC,GAAGT,UAAU,CACrDM,KAAK,EACL,CAAC,MAAM,CAAC,EACR,CAAC,YAAY,EAAE,YAAY,CAC7B,CAAC;EAED,IAAI,CAACC,OAAO,CAACG,IAAI,EAAE;IACjB,OAAAC,iBAAA,CAAQV,EAAE,CAACI,YAAY,EAAAO,YAAA,CAAKH,YAAY,EAAMD,WAAW;EAC3D;EAEA,MAAMK,UAAU,GAAGP,KAAK,CAACO,UAAU,IAAAF,iBAAA,CAAKP,cAAc;IAAA,IAACM,IAAIA,CAAA;MAAA,OAAEP,aAAa,CAACI,OAAO,CAACG,IAAI,CAAC;IAAA;EAAA,EAAI;EAC5F,MAAMI,aAAa,GAAGZ,yBAAyB,CAACK,OAAO,CAACG,IAAI,CAACK,UAAU,EAAE;IACvEC,MAAM,EAAEV,KAAK,CAACS,UAAU;IACxBE,IAAI,EAAEX,KAAK,CAACY;EACd,CAAC,CAAC;EAEF,OAAAP,iBAAA,CAAQV,EAAE,CAACI,YAAY,EAAAO,YAAA,CAAKH,YAAY;IAAEI,UAAU,EAAEA,UAAU;IAAEE,UAAU,EAAED;EAAa;AAC7F","ignoreList":[]}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
export * from "./array-expression.jsx";
|
|
2
|
+
export * from "./arrow-function.jsx";
|
|
1
3
|
export * from "./class-method.js";
|
|
2
4
|
export * from "./function-declaration.js";
|
|
5
|
+
export * from "./function-expression.js";
|
|
6
|
+
export * from "./function-type.js";
|
|
3
7
|
export * from "./interface-declaration.js";
|
|
4
8
|
export * from "./interface-member.js";
|
|
9
|
+
export * from "./interface-method.js";
|
|
5
10
|
export * from "./static-serializers.js";
|
|
6
11
|
export * from "./type-declaration.js";
|
|
7
12
|
export * from "./type-expression.js";
|
|
8
13
|
export * from "./type-transform.js";
|
|
9
14
|
export * from "./union-declaration.js";
|
|
10
15
|
export * from "./union-expression.js";
|
|
16
|
+
export * from "./value-expression.js";
|
|
11
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
export * from "./array-expression.js";
|
|
2
|
+
export * from "./arrow-function.js";
|
|
1
3
|
export * from "./class-method.js";
|
|
2
4
|
export * from "./function-declaration.js";
|
|
5
|
+
export * from "./function-expression.js";
|
|
6
|
+
export * from "./function-type.js";
|
|
3
7
|
export * from "./interface-declaration.js";
|
|
4
8
|
export * from "./interface-member.js";
|
|
9
|
+
export * from "./interface-method.js";
|
|
5
10
|
export * from "./static-serializers.js";
|
|
6
11
|
export * from "./type-declaration.js";
|
|
7
12
|
export * from "./type-expression.js";
|
|
8
13
|
export * from "./type-transform.js";
|
|
9
14
|
export * from "./union-declaration.js";
|
|
10
15
|
export * from "./union-expression.js";
|
|
16
|
+
export * from "./value-expression.js";
|
|
11
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/typescript/components/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,2BAA2B;AACzC,cAAc,4BAA4B;AAC1C,cAAc,uBAAuB;AACrC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,uBAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/typescript/components/index.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA;AACA,cAAc,mBAAmB;AACjC,cAAc,2BAA2B;AACzC,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAClC,cAAc,4BAA4B;AAC1C,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB","ignoreList":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as ay from "@alloy-js/core";
|
|
2
1
|
import { ModelProperty, Operation } from "@typespec/compiler";
|
|
3
2
|
export interface InterfaceMemberProps {
|
|
4
3
|
type: ModelProperty | Operation;
|
|
5
4
|
optional?: boolean;
|
|
6
5
|
}
|
|
7
|
-
export declare function InterfaceMember(props: InterfaceMemberProps):
|
|
6
|
+
export declare function InterfaceMember(props: InterfaceMemberProps): import("@alloy-js/core").Children;
|
|
8
7
|
//# sourceMappingURL=interface-member.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface-member.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-member.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interface-member.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-member.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAM3E,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qCA2B1D"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import * as ay from "@alloy-js/core";
|
|
4
3
|
import * as ts from "@alloy-js/typescript";
|
|
5
4
|
import { isNeverType } from "@typespec/compiler";
|
|
6
5
|
import { $ } from "@typespec/compiler/experimental/typekit";
|
|
7
6
|
import { getHttpPart } from "@typespec/http";
|
|
8
|
-
import {
|
|
7
|
+
import { InterfaceMethod } from "./interface-method.js";
|
|
9
8
|
import { TypeExpression } from "./type-expression.js";
|
|
10
9
|
export function InterfaceMember(props) {
|
|
11
10
|
const namer = ts.useTSNamePolicy();
|
|
@@ -32,24 +31,9 @@ export function InterfaceMember(props) {
|
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
if ($.operation.is(props.type)) {
|
|
35
|
-
|
|
34
|
+
return _$createComponent(InterfaceMethod, {
|
|
36
35
|
get type() {
|
|
37
|
-
return props.type
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const params = _$createComponent(ay.Scope, {
|
|
41
|
-
get children() {
|
|
42
|
-
return _$createComponent(FunctionDeclaration.Parameters, {
|
|
43
|
-
get type() {
|
|
44
|
-
return props.type.parameters;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return _$createComponent(ts.InterfaceMember, {
|
|
50
|
-
name: name,
|
|
51
|
-
get type() {
|
|
52
|
-
return ["(", params, ") => ", returnType];
|
|
36
|
+
return props.type;
|
|
53
37
|
}
|
|
54
38
|
});
|
|
55
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface-member.js","names":["
|
|
1
|
+
{"version":3,"file":"interface-member.js","names":["ts","isNeverType","$","getHttpPart","InterfaceMethod","TypeExpression","InterfaceMember","props","namer","useTSNamePolicy","name","getName","type","modelProperty","is","unpackedType","part","program","_$createComponent","optional","operation"],"sources":["../../../../src/typescript/components/interface-member.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,sBAAsB;AAC1C,SAASC,WAAW,QAAkC,oBAAoB;AAC1E,SAASC,CAAC,QAAQ,yCAAyC;AAC3D,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,eAAe;AACxB,SAASC,cAAc,QAAQ,sBAAsB;AAOrD,OAAO,SAASC,eAAeA,CAACC,KAA2B,EAAE;EAC3D,MAAMC,KAAK,GAAGR,EAAE,CAACS,eAAe,CAAC,CAAC;EAClC,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACJ,KAAK,CAACK,IAAI,CAACF,IAAI,EAAE,sBAAsB,CAAC;EAEnE,IAAIR,CAAC,CAACW,aAAa,CAACC,EAAE,CAACP,KAAK,CAACK,IAAI,CAAC,EAAE;IAClC,IAAIX,WAAW,CAACM,KAAK,CAACK,IAAI,CAACA,IAAI,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IAEA,IAAIG,YAAY,GAAGR,KAAK,CAACK,IAAI,CAACA,IAAI;IAClC,MAAMI,IAAI,GAAGb,WAAW,CAACD,CAAC,CAACe,OAAO,EAAEV,KAAK,CAACK,IAAI,CAACA,IAAI,CAAC;IACpD,IAAII,IAAI,EAAE;MACRD,YAAY,GAAGC,IAAI,CAACJ,IAAI;IAC1B;IAEA,OAAAM,iBAAA,CACGlB,EAAE,CAACM,eAAe;MACjBI,IAAI,EAAEA,IAAI;MAAA,IACVS,QAAQA,CAAA;QAAA,OAAEZ,KAAK,CAACY,QAAQ,IAAIZ,KAAK,CAACK,IAAI,CAACO,QAAQ;MAAA;MAAA,IAC/CP,IAAIA,CAAA;QAAA,OAAAM,iBAAA,CAAGb,cAAc;UAACO,IAAI,EAAEG;QAAY;MAAA;IAAA;EAG9C;EAEA,IAAIb,CAAC,CAACkB,SAAS,CAACN,EAAE,CAACP,KAAK,CAACK,IAAI,CAAC,EAAE;IAC9B,OAAAM,iBAAA,CAAQd,eAAe;MAAA,IAACQ,IAAIA,CAAA;QAAA,OAAEL,KAAK,CAACK,IAAI;MAAA;IAAA;EAC1C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as ts from "@alloy-js/typescript";
|
|
2
|
+
import { Operation } from "@typespec/compiler";
|
|
3
|
+
export interface InterfaceMethodPropsWithType extends Omit<ts.InterfaceMethodProps, "name"> {
|
|
4
|
+
type: Operation;
|
|
5
|
+
name?: string;
|
|
6
|
+
parametersMode?: "prepend" | "append" | "replace";
|
|
7
|
+
}
|
|
8
|
+
export type InterfaceMethodProps = InterfaceMethodPropsWithType | ts.InterfaceMethodProps;
|
|
9
|
+
/**
|
|
10
|
+
* A TypeScript interface method. Pass the `type` prop to create the
|
|
11
|
+
* method by converting from a TypeSpec Operation. Any other props
|
|
12
|
+
* provided will take precedence.
|
|
13
|
+
*/
|
|
14
|
+
export declare function InterfaceMethod(props: Readonly<InterfaceMethodProps>): import("@alloy-js/core/jsx-runtime").Children;
|
|
15
|
+
//# sourceMappingURL=interface-method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-method.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-method.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACzF,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,MAAM,oBAAoB,GAAG,4BAA4B,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAE1F;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,iDA8BpE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { splitProps } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import * as ts from "@alloy-js/typescript";
|
|
5
|
+
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
6
|
+
import { TypeExpression } from "./type-expression.js";
|
|
7
|
+
/**
|
|
8
|
+
* A TypeScript interface method. Pass the `type` prop to create the
|
|
9
|
+
* method by converting from a TypeSpec Operation. Any other props
|
|
10
|
+
* provided will take precedence.
|
|
11
|
+
*/
|
|
12
|
+
export function InterfaceMethod(props) {
|
|
13
|
+
const isTypeSpecTyped = "type" in props;
|
|
14
|
+
if (!isTypeSpecTyped) {
|
|
15
|
+
return _$createComponent(ts.InterfaceMethod, props);
|
|
16
|
+
}
|
|
17
|
+
const [efProps, updateProps, forwardProps] = splitProps(props, ["type"], ["returnType", "parameters"]);
|
|
18
|
+
const name = props.name ? props.name : ts.useTSNamePolicy().getName(efProps.type.name, "function");
|
|
19
|
+
const returnType = props.returnType ?? _$createComponent(TypeExpression, {
|
|
20
|
+
get type() {
|
|
21
|
+
return getReturnType(efProps.type);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const allParameters = buildParameterDescriptors(efProps.type.parameters, {
|
|
25
|
+
params: props.parameters,
|
|
26
|
+
mode: props.parametersMode
|
|
27
|
+
});
|
|
28
|
+
return _$createComponent(ts.InterfaceMethod, _$mergeProps(forwardProps, {
|
|
29
|
+
name: name,
|
|
30
|
+
returnType: returnType,
|
|
31
|
+
parameters: allParameters
|
|
32
|
+
}, updateProps));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=interface-method.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-method.js","names":["splitProps","ts","buildParameterDescriptors","getReturnType","TypeExpression","InterfaceMethod","props","isTypeSpecTyped","_$createComponent","efProps","updateProps","forwardProps","name","useTSNamePolicy","getName","type","returnType","allParameters","parameters","params","mode","parametersMode","_$mergeProps"],"sources":["../../../../src/typescript/components/interface-method.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,UAAU,QAAQ,4BAA4B;AACvD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,yBAAyB,EAAEC,aAAa,QAAQ,uBAAuB;AAChF,SAASC,cAAc;AAUvB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAAqC,EAAE;EACrE,MAAMC,eAAe,GAAG,MAAM,IAAID,KAAK;EACvC,IAAI,CAACC,eAAe,EAAE;IACpB,OAAAC,iBAAA,CAAQP,EAAE,CAACI,eAAe,EAAKC,KAAK;EACtC;EAEA,MAAM,CAACG,OAAO,EAAEC,WAAW,EAAEC,YAAY,CAAC,GAAGX,UAAU,CACrDM,KAAK,EACL,CAAC,MAAM,CAAC,EACR,CAAC,YAAY,EAAE,YAAY,CAC7B,CAAC;EAED,MAAMM,IAAI,GAAGN,KAAK,CAACM,IAAI,GACnBN,KAAK,CAACM,IAAI,GACVX,EAAE,CAACY,eAAe,CAAC,CAAC,CAACC,OAAO,CAACL,OAAO,CAACM,IAAI,CAACH,IAAI,EAAE,UAAU,CAAC;EAC/D,MAAMI,UAAU,GAAGV,KAAK,CAACU,UAAU,IAAAR,iBAAA,CAAKJ,cAAc;IAAA,IAACW,IAAIA,CAAA;MAAA,OAAEZ,aAAa,CAACM,OAAO,CAACM,IAAI,CAAC;IAAA;EAAA,EAAI;EAC5F,MAAME,aAAa,GAAGf,yBAAyB,CAACO,OAAO,CAACM,IAAI,CAACG,UAAU,EAAE;IACvEC,MAAM,EAAEb,KAAK,CAACY,UAAU;IACxBE,IAAI,EAAEd,KAAK,CAACe;EACd,CAAC,CAAC;EAEF,OAAAb,iBAAA,CACGP,EAAE,CAACI,eAAe,EAAAiB,YAAA,CACbX,YAAY;IAChBC,IAAI,EAAEA,IAAI;IACVI,UAAU,EAAEA,UAAU;IACtBE,UAAU,EAAED;EAAa,GACrBP,WAAW;AAGrB","ignoreList":[]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
|
-
import {
|
|
2
|
+
import { Type } from "@typespec/compiler";
|
|
3
3
|
export interface TypedAliasDeclarationProps extends Omit<ts.TypeDeclarationProps, "name"> {
|
|
4
|
-
type:
|
|
4
|
+
type: Type;
|
|
5
5
|
name?: string;
|
|
6
6
|
}
|
|
7
7
|
export type TypeAliasDeclarationProps = TypedAliasDeclarationProps | ts.TypeDeclarationProps;
|
|
8
|
+
/**
|
|
9
|
+
* Create a TypeScript type alias declaration. Pass the `type` prop to emit the
|
|
10
|
+
* type alias as the provided TypeSpec type.
|
|
11
|
+
*/
|
|
8
12
|
export declare function TypeAliasDeclaration(props: TypeAliasDeclarationProps): import("@alloy-js/core").Children;
|
|
9
13
|
//# sourceMappingURL=type-alias-declaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-alias-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/type-alias-declaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"type-alias-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/type-alias-declaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAK1C,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACvF,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,yBAAyB,GAAG,0BAA0B,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,qCAoBpE"}
|
|
@@ -6,6 +6,10 @@ import * as ts from "@alloy-js/typescript";
|
|
|
6
6
|
import { $ } from "@typespec/compiler/experimental/typekit";
|
|
7
7
|
import { reportDiagnostic } from "../../lib.js";
|
|
8
8
|
import { TypeExpression } from "./type-expression.js";
|
|
9
|
+
/**
|
|
10
|
+
* Create a TypeScript type alias declaration. Pass the `type` prop to emit the
|
|
11
|
+
* type alias as the provided TypeSpec type.
|
|
12
|
+
*/
|
|
9
13
|
export function TypeAliasDeclaration(props) {
|
|
10
14
|
if (!isTypedAliasDeclarationProps(props)) {
|
|
11
15
|
return _$createComponent(ts.TypeDeclaration, _$mergeProps(props, {
|
|
@@ -14,7 +18,7 @@ export function TypeAliasDeclaration(props) {
|
|
|
14
18
|
}
|
|
15
19
|
}));
|
|
16
20
|
}
|
|
17
|
-
const originalName = props.name ?? props.type.name;
|
|
21
|
+
const originalName = props.name ?? ("name" in props.type && typeof props.type.name === "string" ? props.type.name : "");
|
|
18
22
|
if (!originalName || originalName === "") {
|
|
19
23
|
reportDiagnostic($.program, {
|
|
20
24
|
code: "type-declaration-missing-name",
|
|
@@ -31,7 +35,8 @@ export function TypeAliasDeclaration(props) {
|
|
|
31
35
|
return [_$createComponent(TypeExpression, {
|
|
32
36
|
get type() {
|
|
33
37
|
return props.type;
|
|
34
|
-
}
|
|
38
|
+
},
|
|
39
|
+
noReference: true
|
|
35
40
|
}), _$memo(() => props.children)];
|
|
36
41
|
}
|
|
37
42
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-alias-declaration.js","names":["refkey","getRefkey","ts","$","reportDiagnostic","TypeExpression","TypeAliasDeclaration","props","isTypedAliasDeclarationProps","_$createComponent","TypeDeclaration","_$mergeProps","children","originalName","name","type","program","code","target","useTSNamePolicy","getName","_$memo"],"sources":["../../../../src/typescript/components/type-alias-declaration.tsx"],"sourcesContent":[null],"mappings":";;;AAAA,SAASA,MAAM,IAAIC,SAAS,QAAQ,gBAAgB;AACpD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,CAAC,QAAQ,yCAAyC;AAC3D,SAASC,gBAAgB,QAAQ,cAAc;AAC/C,SAASC,cAAc;AASvB,OAAO,SAASC,oBAAoBA,CAACC,KAAgC,EAAE;EACrE,IAAI,CAACC,4BAA4B,CAACD,KAAK,CAAC,EAAE;IACxC,OAAAE,iBAAA,CAAQP,EAAE,CAACQ,eAAe,EAAAC,YAAA,CAAKJ,KAAK;MAAA,IAAAK,SAAA;QAAA,OAAGL,KAAK,CAACK,QAAQ;MAAA;IAAA;EACvD;EAEA,MAAMC,YAAY,
|
|
1
|
+
{"version":3,"file":"type-alias-declaration.js","names":["refkey","getRefkey","ts","$","reportDiagnostic","TypeExpression","TypeAliasDeclaration","props","isTypedAliasDeclarationProps","_$createComponent","TypeDeclaration","_$mergeProps","children","originalName","name","type","program","code","target","useTSNamePolicy","getName","noReference","_$memo"],"sources":["../../../../src/typescript/components/type-alias-declaration.tsx"],"sourcesContent":[null],"mappings":";;;AAAA,SAASA,MAAM,IAAIC,SAAS,QAAQ,gBAAgB;AACpD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,CAAC,QAAQ,yCAAyC;AAC3D,SAASC,gBAAgB,QAAQ,cAAc;AAC/C,SAASC,cAAc;A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","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/type-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAM1C,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE1E,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"type-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/type-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAM1C,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE1E,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qCAkB1D"}
|
|
@@ -30,6 +30,10 @@ export function TypeDeclaration(props) {
|
|
|
30
30
|
return _$createComponent(TypeAliasDeclaration, _$mergeProps({
|
|
31
31
|
type: type
|
|
32
32
|
}, restProps));
|
|
33
|
+
case "Operation":
|
|
34
|
+
return _$createComponent(TypeAliasDeclaration, _$mergeProps({
|
|
35
|
+
type: type
|
|
36
|
+
}, restProps));
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
//# sourceMappingURL=type-declaration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-declaration.js","names":["ts","EnumDeclaration","InterfaceDeclaration","TypeAliasDeclaration","UnionDeclaration","TypeDeclaration","props","type","_$createComponent","restProps","kind","_$mergeProps"],"sources":["../../../../src/typescript/components/type-declaration.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,sBAAsB;AAE1C,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AASzB,OAAO,SAASC,eAAeA,CAACC,KAA2B,EAAE;EAC3D,IAAI,CAACA,KAAK,CAACC,IAAI,EAAE;IACf,OAAAC,iBAAA,CAAQR,EAAE,CAACK,eAAe,EAAMC,KAAK;EACvC;EAEA,MAAM;IAAEC,IAAI;IAAE,GAAGE;EAAU,CAAC,GAAGH,KAAK;EACpC,QAAQC,IAAI,CAACG,IAAI;IACf,KAAK,OAAO;MACV,OAAAF,iBAAA,CAAQN,oBAAoB,EAAAS,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;IACxD,KAAK,OAAO;MACV,OAAAD,iBAAA,CAAQJ,gBAAgB,EAAAO,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;IACpD,KAAK,MAAM;MACT,OAAAD,iBAAA,CAAQP,eAAe,EAAAU,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;IACnD,KAAK,QAAQ;MACX,OAAAD,iBAAA,CAAQL,oBAAoB,EAAAQ,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;EAC1D;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"type-declaration.js","names":["ts","EnumDeclaration","InterfaceDeclaration","TypeAliasDeclaration","UnionDeclaration","TypeDeclaration","props","type","_$createComponent","restProps","kind","_$mergeProps"],"sources":["../../../../src/typescript/components/type-declaration.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,sBAAsB;AAE1C,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AASzB,OAAO,SAASC,eAAeA,CAACC,KAA2B,EAAE;EAC3D,IAAI,CAACA,KAAK,CAACC,IAAI,EAAE;IACf,OAAAC,iBAAA,CAAQR,EAAE,CAACK,eAAe,EAAMC,KAAK;EACvC;EAEA,MAAM;IAAEC,IAAI;IAAE,GAAGE;EAAU,CAAC,GAAGH,KAAK;EACpC,QAAQC,IAAI,CAACG,IAAI;IACf,KAAK,OAAO;MACV,OAAAF,iBAAA,CAAQN,oBAAoB,EAAAS,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;IACxD,KAAK,OAAO;MACV,OAAAD,iBAAA,CAAQJ,gBAAgB,EAAAO,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;IACpD,KAAK,MAAM;MACT,OAAAD,iBAAA,CAAQP,eAAe,EAAAU,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;IACnD,KAAK,QAAQ;MACX,OAAAD,iBAAA,CAAQL,oBAAoB,EAAAQ,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;IACxD,KAAK,WAAW;MACd,OAAAD,iBAAA,CAAQL,oBAAoB,EAAAQ,YAAA;QAACJ,IAAI,EAAEA;MAAI,GAAME,SAAS;EAC1D;AACF","ignoreList":[]}
|
|
@@ -2,6 +2,12 @@ import { Type } from "@typespec/compiler";
|
|
|
2
2
|
import "@typespec/http/experimental/typekit";
|
|
3
3
|
export interface TypeExpressionProps {
|
|
4
4
|
type: Type;
|
|
5
|
+
/**
|
|
6
|
+
* Whether to disallow references. Setting this will force the type to be
|
|
7
|
+
* emitted inline, even if it is a declaration that would otherwise be
|
|
8
|
+
* referenced.
|
|
9
|
+
*/
|
|
10
|
+
noReference?: boolean;
|
|
5
11
|
}
|
|
6
12
|
export declare function TypeExpression(props: TypeExpressionProps): import("@alloy-js/core").Children;
|
|
7
13
|
//# sourceMappingURL=type-expression.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/type-expression.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgC,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"type-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/type-expression.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgC,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,qCAAqC,CAAC;AAQ7C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;IAEX;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,qCAyDxD"}
|
|
@@ -6,12 +6,13 @@ import { $ } from "@typespec/compiler/experimental/typekit";
|
|
|
6
6
|
import "@typespec/http/experimental/typekit";
|
|
7
7
|
import { reportTypescriptDiagnostic } from "../../typescript/lib.js";
|
|
8
8
|
import { ArrayExpression } from "./array-expression.js";
|
|
9
|
+
import { FunctionType } from "./function-type.js";
|
|
9
10
|
import { InterfaceExpression } from "./interface-declaration.js";
|
|
10
11
|
import { RecordExpression } from "./record-expression.js";
|
|
11
12
|
import { UnionExpression } from "./union-expression.js";
|
|
12
13
|
export function TypeExpression(props) {
|
|
13
14
|
const type = $.httpPart.unpack(props.type);
|
|
14
|
-
if (isDeclaration(type)) {
|
|
15
|
+
if (!props.noReference && isDeclaration(type)) {
|
|
15
16
|
// todo: probably need abstraction around deciding what's a declaration in the output
|
|
16
17
|
// (it may not correspond to things which are declarations in TypeSpec?)
|
|
17
18
|
return _$createComponent(Reference, {
|
|
@@ -84,6 +85,10 @@ export function TypeExpression(props) {
|
|
|
84
85
|
return _$createComponent(InterfaceExpression, {
|
|
85
86
|
type: type
|
|
86
87
|
});
|
|
88
|
+
case "Operation":
|
|
89
|
+
return _$createComponent(FunctionType, {
|
|
90
|
+
type: type
|
|
91
|
+
});
|
|
87
92
|
default:
|
|
88
93
|
reportTypescriptDiagnostic($.program, {
|
|
89
94
|
code: "typescript-unsupported-type",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-expression.js","names":["For","refkey","Reference","ValueExpression","$","reportTypescriptDiagnostic","ArrayExpression","InterfaceExpression","RecordExpression","UnionExpression","TypeExpression","props","type","httpPart","unpack","isDeclaration","_$createComponent","kind","_$memo","getScalarIntrinsicExpression","jsValue","value","each","values","comma","line","children","element","array","is","elementType","indexer","record","partType","program","code","target","intrinsicNameToTSType","Map","intrinsicName","scalar","isUtcDateTime","extendsUtcDateTime","encoding","getEncoding","emittedType","getStdBase","name","tsType","get","Boolean"],"sources":["../../../../src/typescript/components/type-expression.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,GAAG,EAAEC,MAAM,QAAQ,gBAAgB;AAC5C,SAASC,SAAS,EAAEC,eAAe,QAAQ,sBAAsB;AAEjE,SAASC,CAAC,QAAQ,yCAAyC;AAC3D,OAAO,qCAAqC;AAC5C,SAASC,0BAA0B,QAAQ,yBAAyB;AACpE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,eAAe,QAAQ,uBAAuB;
|
|
1
|
+
{"version":3,"file":"type-expression.js","names":["For","refkey","Reference","ValueExpression","$","reportTypescriptDiagnostic","ArrayExpression","FunctionType","InterfaceExpression","RecordExpression","UnionExpression","TypeExpression","props","type","httpPart","unpack","noReference","isDeclaration","_$createComponent","kind","_$memo","getScalarIntrinsicExpression","jsValue","value","each","values","comma","line","children","element","array","is","elementType","indexer","record","partType","program","code","target","intrinsicNameToTSType","Map","intrinsicName","scalar","isUtcDateTime","extendsUtcDateTime","encoding","getEncoding","emittedType","getStdBase","name","tsType","get","Boolean"],"sources":["../../../../src/typescript/components/type-expression.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAASA,GAAG,EAAEC,MAAM,QAAQ,gBAAgB;AAC5C,SAASC,SAAS,EAAEC,eAAe,QAAQ,sBAAsB;AAEjE,SAASC,CAAC,QAAQ,yCAAyC;AAC3D,OAAO,qCAAqC;AAC5C,SAASC,0BAA0B,QAAQ,yBAAyB;AACpE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,eAAe,QAAQ,uBAAuB;AAavD,OAAO,SAASC,cAAcA,CAACC,KAA0B,EAAE;EACzD,MAAMC,IAAI,GAAGT,CAAC,CAACU,QAAQ,CAACC,MAAM,CAACH,KAAK,CAACC,IAAI,CAAC;EAC1C,IAAI,CAACD,KAAK,CAACI,WAAW,IAAIC,aAAa,CAACJ,IAAI,CAAC,EAAE;IAC7C;IACA;IACA,OAAAK,iBAAA,CAAQhB,SAAS;MAAA,IAACD,MAAMA,CAAA;QAAA,OAAEA,MAAM,CAACY,IAAI,CAAC;MAAA;IAAA;IACtC;EACF;;EAEA;EACA,QAAQA,IAAI,CAACM,IAAI;IACf,KAAK,QAAQ;IACb,KAAK,WAAW;MACd,QAAAC,MAAA,OAAUC,4BAA4B,CAACR,IAAI,CAAC;IAC9C,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,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,CAAC;EAEvD,IAAI,CAACS,MAAM,EAAE;IACX7C,0BAA0B,CAACD,CAAC,CAACgC,OAAO,EAAE;MAAEC,IAAI,EAAE,+BAA+B;MAAEC,MAAM,EAAEzB;IAAK,CAAC,CAAC;IAC9F,OAAO,KAAK;EACd;EAEA,OAAOqC,MAAM;AACf;AAEA,SAASjC,aAAaA,CAACJ,IAAU,EAAW;EAC1C,QAAQA,IAAI,CAACM,IAAI;IACf,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,MAAM;IACX,KAAK,WAAW;IAChB,KAAK,YAAY;MACf,OAAO,IAAI;IACb,KAAK,cAAc;MACjB,OAAO,KAAK;IAEd,KAAK,OAAO;MACV,IAAIf,CAAC,CAAC0B,KAAK,CAACC,EAAE,CAAClB,IAAI,CAAC,IAAIT,CAAC,CAAC8B,MAAM,CAACH,EAAE,CAAClB,IAAI,CAAC,EAAE;QACzC,OAAO,KAAK;MACd;MAEA,OAAOuC,OAAO,CAACvC,IAAI,CAACoC,IAAI,CAAC;IAC3B,KAAK,OAAO;MACV,OAAOG,OAAO,CAACvC,IAAI,CAACoC,IAAI,CAAC;IAC3B;MACE,OAAO,KAAK;EAChB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-function.test.d.ts","sourceRoot":"","sources":["../../../../test/typescript/components/arrow-function.test.tsx"],"names":[],"mappings":""}
|