11import { TypeSystem } from '../../system' ;
2+ import { toTypeScriptAst } from '../../typescript/converter' ;
23
34describe ( 'any' , ( ) => {
45 test ( 'can encode "any" type' , ( ) => {
56 const system = new TypeSystem ( ) ;
67 const type = system . t . any ;
7- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
8+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
89 node : 'AnyKeyword' ,
910 } ) ;
1011 } ) ;
@@ -14,7 +15,7 @@ describe('const', () => {
1415 test ( 'can handle number const' , ( ) => {
1516 const system = new TypeSystem ( ) ;
1617 const type = system . t . Const < 123 > ( 123 ) ;
17- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
18+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
1819 node : 'NumericLiteral' ,
1920 text : '123' ,
2021 } ) ;
@@ -23,31 +24,31 @@ describe('const', () => {
2324 test ( 'can handle null' , ( ) => {
2425 const system = new TypeSystem ( ) ;
2526 const type = system . t . Const < null > ( null ) ;
26- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
27+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
2728 node : 'NullKeyword' ,
2829 } ) ;
2930 } ) ;
3031
3132 test ( 'can handle "true"' , ( ) => {
3233 const system = new TypeSystem ( ) ;
3334 const type = system . t . Const < true > ( true ) ;
34- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
35+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
3536 node : 'TrueKeyword' ,
3637 } ) ;
3738 } ) ;
3839
3940 test ( 'can handle "false"' , ( ) => {
4041 const system = new TypeSystem ( ) ;
4142 const type = system . t . Const < false > ( false ) ;
42- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
43+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
4344 node : 'FalseKeyword' ,
4445 } ) ;
4546 } ) ;
4647
4748 test ( 'can handle string' , ( ) => {
4849 const system = new TypeSystem ( ) ;
4950 const type = system . t . Const < 'asdf' > ( 'asdf' ) ;
50- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
51+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
5152 node : 'StringLiteral' ,
5253 text : 'asdf' ,
5354 } ) ;
@@ -56,7 +57,7 @@ describe('const', () => {
5657 test ( 'complex objects' , ( ) => {
5758 const system = new TypeSystem ( ) ;
5859 const type = system . t . Const ( { foo : 'bar' } as const ) ;
59- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
60+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
6061 node : 'ObjectKeyword' ,
6162 } ) ;
6263 } ) ;
@@ -66,7 +67,7 @@ describe('bool', () => {
6667 test ( 'can emit boolean AST' , ( ) => {
6768 const system = new TypeSystem ( ) ;
6869 const type = system . t . bool ;
69- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
70+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
7071 node : 'BooleanKeyword' ,
7172 } ) ;
7273 } ) ;
@@ -76,7 +77,7 @@ describe('num', () => {
7677 test ( 'can emit number AST' , ( ) => {
7778 const system = new TypeSystem ( ) ;
7879 const type = system . t . num ;
79- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
80+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
8081 node : 'NumberKeyword' ,
8182 } ) ;
8283 } ) ;
@@ -86,7 +87,7 @@ describe('str', () => {
8687 test ( 'can emit string AST' , ( ) => {
8788 const system = new TypeSystem ( ) ;
8889 const type = system . t . str ;
89- expect ( type . toTypeScriptAst ( ) ) . toEqual ( {
90+ expect ( toTypeScriptAst ( type ) ) . toEqual ( {
9091 node : 'StringKeyword' ,
9192 } ) ;
9293 } ) ;
@@ -96,7 +97,7 @@ describe('bin', () => {
9697 test ( 'can emit binary AST' , ( ) => {
9798 const system = new TypeSystem ( ) ;
9899 const type = system . t . bin ;
99- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
100+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
100101 {
101102 "id": {
102103 "name": "Uint8Array",
@@ -112,7 +113,7 @@ describe('arr', () => {
112113 test ( 'can emit array of "any" AST' , ( ) => {
113114 const system = new TypeSystem ( ) ;
114115 const type = system . t . arr ;
115- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
116+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
116117 {
117118 "elementType": {
118119 "node": "AnyKeyword",
@@ -125,7 +126,7 @@ describe('arr', () => {
125126 test ( 'can emit array of "string" AST' , ( ) => {
126127 const system = new TypeSystem ( ) ;
127128 const type = system . t . Array ( system . t . str ) ;
128- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
129+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
129130 {
130131 "elementType": {
131132 "node": "StringKeyword",
@@ -140,8 +141,8 @@ describe('tup', () => {
140141 test ( 'can emit tuple AST' , ( ) => {
141142 const system = new TypeSystem ( ) ;
142143 const { t} = system ;
143- const type = system . t . Tuple ( t . str , t . num , t . bool ) ;
144- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
144+ const type = system . t . tuple ( t . str , t . num , t . bool ) ;
145+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
145146 {
146147 "elements": [
147148 {
@@ -154,7 +155,7 @@ describe('tup', () => {
154155 "node": "BooleanKeyword",
155156 },
156157 ],
157- "node": "TupType ",
158+ "node": "TupleType ",
158159 }
159160 ` ) ;
160161 } ) ;
@@ -176,7 +177,7 @@ describe('obj', () => {
176177 title : 'title' ,
177178 description : 'description' ,
178179 } ) ;
179- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
180+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
180181{
181182 "comment": "# title
182183
@@ -215,7 +216,7 @@ describe('map', () => {
215216 title : 'title' ,
216217 description : 'description' ,
217218 } ) ;
218- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
219+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
219220 {
220221 "node": "TypeReference",
221222 "typeArguments": [
@@ -237,7 +238,7 @@ describe('ref', () => {
237238 const system = new TypeSystem ( ) ;
238239 const { t} = system ;
239240 const type = system . t . Ref ( 'Foo' ) ;
240- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
241+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
241242 {
242243 "id": {
243244 "name": "Foo",
@@ -254,7 +255,7 @@ describe('or', () => {
254255 const system = new TypeSystem ( ) ;
255256 const { t} = system ;
256257 const type = system . t . Or ( t . str , t . num ) ;
257- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
258+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
258259 {
259260 "node": "UnionType",
260261 "types": [
@@ -275,7 +276,7 @@ describe('fn', () => {
275276 const system = new TypeSystem ( ) ;
276277 const { t} = system ;
277278 const type = system . t . Function ( t . str , t . num ) ;
278- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
279+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
279280{
280281 "node": "FnType",
281282 "parameters": [
@@ -312,7 +313,7 @@ describe('fn$', () => {
312313 const system = new TypeSystem ( ) ;
313314 const { t} = system ;
314315 const type = system . t . Function$ ( t . str , t . num ) ;
315- expect ( type . toTypeScriptAst ( ) ) . toMatchInlineSnapshot ( `
316+ expect ( toTypeScriptAst ( type ) ) . toMatchInlineSnapshot ( `
316317{
317318 "node": "FnType",
318319 "parameters": [
0 commit comments