ts2workflows 0.3.0 → 0.5.0
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/README.md +6 -2
- package/dist/ast/expressions.d.ts.map +1 -1
- package/dist/ast/expressions.js +7 -10
- package/dist/ast/stepnames.d.ts.map +1 -1
- package/dist/ast/stepnames.js +11 -1
- package/dist/ast/steps.d.ts +24 -13
- package/dist/ast/steps.d.ts.map +1 -1
- package/dist/ast/steps.js +54 -38
- package/dist/transpiler/expressions.d.ts +8 -4
- package/dist/transpiler/expressions.d.ts.map +1 -1
- package/dist/transpiler/expressions.js +162 -42
- package/dist/transpiler/index.d.ts.map +1 -1
- package/dist/transpiler/index.js +29 -28
- package/dist/transpiler/statements.d.ts +2 -1
- package/dist/transpiler/statements.d.ts.map +1 -1
- package/dist/transpiler/statements.js +137 -155
- package/dist/transpiler/transformations.d.ts.map +1 -1
- package/dist/transpiler/transformations.js +216 -110
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -0
- package/language_reference.md +55 -33
- package/package.json +11 -4
- package/types/global.d.ts +124 -0
- package/dist/transpiler/asserts.d.ts +0 -7
- package/dist/transpiler/asserts.d.ts.map +0 -1
- package/dist/transpiler/asserts.js +0 -11
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export {}
|
|
2
|
+
|
|
3
|
+
/// <reference no-default-lib="true"/>
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
// Minimal definition of Symbol.iterator required by the for-of statement
|
|
7
|
+
interface SymbolConstructor {
|
|
8
|
+
readonly iterator: unique symbol
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var Symbol: SymbolConstructor
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Iterator types copied from lib.es2015.iterable.d.ts
|
|
15
|
+
*/
|
|
16
|
+
interface Iterator<T, TReturn = any, TNext = undefined> {
|
|
17
|
+
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
|
18
|
+
next(...args: [] | [TNext]): IteratorResult<T, TReturn>
|
|
19
|
+
return?(value?: TReturn): IteratorResult<T, TReturn>
|
|
20
|
+
throw?(e?: any): IteratorResult<T, TReturn>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Iterable<T> {
|
|
24
|
+
[Symbol.iterator](): Iterator<T>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface IterableIterator<T> extends Iterator<T> {
|
|
28
|
+
[Symbol.iterator](): IterableIterator<T>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface Array<T> {
|
|
32
|
+
// Array member access
|
|
33
|
+
[n: number]: T
|
|
34
|
+
|
|
35
|
+
// Arrays can be iterated by the for-of statement
|
|
36
|
+
[Symbol.iterator](): IterableIterator<T>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface ArrayConstructor {
|
|
40
|
+
isArray(arg: any): arg is any[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var Array: ArrayConstructor
|
|
44
|
+
|
|
45
|
+
interface Boolean {}
|
|
46
|
+
interface CallableFunction {}
|
|
47
|
+
interface Function {}
|
|
48
|
+
interface IArguments {}
|
|
49
|
+
interface NewableFunction {}
|
|
50
|
+
interface Number {}
|
|
51
|
+
interface Object {}
|
|
52
|
+
interface RegExp {}
|
|
53
|
+
interface String {}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Utility types
|
|
57
|
+
* Copied from lib.es5.d.ts
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Make all properties in T optional
|
|
62
|
+
*/
|
|
63
|
+
type Partial<T> = {
|
|
64
|
+
[P in keyof T]?: T[P]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Make all properties in T required
|
|
69
|
+
*/
|
|
70
|
+
type Required<T> = {
|
|
71
|
+
[P in keyof T]-?: T[P]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Make all properties in T readonly
|
|
76
|
+
*/
|
|
77
|
+
type Readonly<T> = {
|
|
78
|
+
readonly [P in keyof T]: T[P]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* From T, pick a set of properties whose keys are in the union K
|
|
83
|
+
*/
|
|
84
|
+
type Pick<T, K extends keyof T> = {
|
|
85
|
+
[P in K]: T[P]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Construct a type with a set of properties K of type T
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
type Record<K extends keyof any, T> = {
|
|
93
|
+
[P in K]: T
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Obtain the return type of a function type
|
|
98
|
+
*/
|
|
99
|
+
type ReturnType<T extends (...args: any) => any> = T extends (
|
|
100
|
+
...args: any
|
|
101
|
+
) => infer R
|
|
102
|
+
? R
|
|
103
|
+
: any
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Exclude from T those types that are assignable to U
|
|
107
|
+
*/
|
|
108
|
+
type Exclude<T, U> = T extends U ? never : T
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Extract from T those types that are assignable to U
|
|
112
|
+
*/
|
|
113
|
+
type Extract<T, U> = T extends U ? T : never
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Construct a type with the properties of T except for those in type K.
|
|
117
|
+
*/
|
|
118
|
+
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Exclude null and undefined from T
|
|
122
|
+
*/
|
|
123
|
+
type NonNullable<T> = T & {}
|
|
124
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asserts.d.ts","sourceRoot":"","sources":["../../src/transpiler/asserts.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAM7E;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACtB,qBAAqB,EAAE,MAAM,EAAE,GAC9B,IAAI,CAMN"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { InternalTranspilingError } from '../errors.js';
|
|
2
|
-
export function assertType(node, expectedType) {
|
|
3
|
-
if (node?.type !== expectedType) {
|
|
4
|
-
throw new InternalTranspilingError(`Expected ${expectedType}, got ${node?.type}`);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export function assertOneOfManyTypes(node, expectAnyOfTheseTypes) {
|
|
8
|
-
if (!expectAnyOfTheseTypes.includes(node?.type)) {
|
|
9
|
-
throw new InternalTranspilingError(`Expected ${expectAnyOfTheseTypes.join(' or ')}, got ${node?.type}`);
|
|
10
|
-
}
|
|
11
|
-
}
|