Skip to content

Commit 371c771

Browse files
committed
Changes to examples.
1 parent 7eac131 commit 371c771

File tree

9 files changed

+84
-115
lines changed

9 files changed

+84
-115
lines changed

src/playground/run.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22
import * as tsr from '../';
33

4-
tsr.transform(path.join(__dirname, './snippets/source4.ts'), {
5-
compilerOptions: {}
6-
});
4+
const args = process.argv.slice(2);
5+
const file = path.join(__dirname, `./snippets/${args[0]}.ts`);
6+
7+
tsr.transform(file, { keepTempFiles: true });

src/playground/snippets/.tsr/source3.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/playground/snippets/.tsr/source4.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/playground/snippets/source3.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/playground/snippets/source4.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/playground/snippets/source5.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { test } from './source6';
2+
// Variable with implicit complex type
3+
let _aType = t.array(t.number()), a = _aType.assert(test());
4+
// Constant with implicit complex type
5+
const b = t.array(t.number()).assert(test());
6+
// Variable reassignment
7+
a = _aType.assert(19);
8+
// Constant with explicit any type
9+
const c = 10;
10+
// Variable with explicit any type
11+
let d = 'foo';
12+
d = 'bar';
13+
// Variable with implicit any type
14+
let f;
15+
f = 'hi';
16+
// Variable with explicit complex type
17+
let _gType = t.array(t.ref(Symbol)), g;
18+
g = _gType.assert([Symbol(1), Symbol(2)]);
19+
let _hType = t.union(t.void(), t.null()), h;
20+
let _iType = t.union(t.number(), t.array(t.array(t.boolean())), t.ref(Symbol)), i;
21+
let _jType = t.void(), j;
22+
let _kType = t.null(), k;
23+
let _lType = t.ref(Symbol), l;
24+
let _mType = t.this(this), m;
25+
// Variable with implicit complex type
26+
let _eType = t.array(t.union(t.string(), t.number())), e = _eType.assert(['one', 10, 'three']);
27+
e = _eType.assert('hello');
28+
let _nType = t.number(10), n;
29+
let _oType = t.boolean(true), o;
30+
let _pType = t.string("str"), p;
31+
let _qType = t.boolean(false), q;
32+
let _nType = t.ref(o), n;

src/playground/snippets/source5.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { test } from './source6';
2+
3+
// Variable with implicit complex type
4+
let a = test();
5+
6+
// Constant with implicit complex type
7+
const b = test();
8+
9+
// Variable reassignment
10+
a = 19;
11+
12+
// Constant with explicit any type
13+
const c: any = 10;
14+
15+
// Variable with explicit any type
16+
let d: any = 'foo';
17+
d = 'bar';
18+
19+
// Variable with implicit any type
20+
let f;
21+
f = 'hi';
22+
23+
// Variable with explicit complex type
24+
let g: Symbol[];
25+
g = [Symbol(1), Symbol(2)];
26+
27+
let h: void;
28+
let i: number | boolean[][] | Symbol;
29+
let j: undefined;
30+
let k: null;
31+
let l: symbol;
32+
let m: this;
33+
34+
// Variable with implicit complex type
35+
let e = ['one', 10, 'three'];
36+
e = 'hello';
37+
38+
let n: 10;
39+
let o: true;
40+
let p: 'str';
41+
let q: false;
42+
let n: o;

src/playground/snippets/source6.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function test() {
2+
return [5, 10, 2];
3+
}

src/playground/snippets/source6.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function test() {
2+
return [5, 10, 2];
3+
}

0 commit comments

Comments
 (0)