Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02e10a5

Browse filesBrowse files
joyeecheungdanielleadams
authored andcommitted
test: test snapshotting TypeScript compiler
PR-URL: #38905 Refs: #35711 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c5e04c5 commit 02e10a5
Copy full SHA for 02e10a5

File tree

Expand file treeCollapse file tree

5 files changed

+168841
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+168841
-0
lines changed
Open diff view settings
Collapse file
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var VirtualPoint = /** @class */ (function () {
2+
function VirtualPoint(x, y) {
3+
this.x = x;
4+
this.y = y;
5+
}
6+
return VirtualPoint;
7+
}());
8+
var newVPoint = new VirtualPoint(13, 56);
Collapse file
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class VirtualPoint {
2+
x: number;
3+
y: number;
4+
5+
constructor(x: number, y: number) {
6+
this.x = x;
7+
this.y = y;
8+
}
9+
}
10+
11+
const newVPoint = new VirtualPoint(13, 56);
Collapse file
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This file is to be concatenated with
2+
// https://github.com/microsoft/TypeScript/blob/main/lib/typescript.js
3+
// to produce a snapshot that reads a file path from the command
4+
// line and compile it into JavaScript, then write the
5+
// result into another file.
6+
7+
const fs = require('fs');
8+
const v8 = require('v8');
9+
const assert = require('assert');
10+
11+
v8.startupSnapshot.setDeserializeMainFunction(( { ts }) => {
12+
const input = process.argv[1];
13+
const output = process.argv[2];
14+
console.error(`Compiling ${input} to ${output}`);
15+
assert(input);
16+
assert(output);
17+
const source = fs.readFileSync(input, 'utf8');
18+
19+
let result = ts.transpileModule(
20+
source,
21+
{
22+
compilerOptions: {
23+
module: ts.ModuleKind.CommonJS
24+
}
25+
});
26+
27+
fs.writeFileSync(output, result.outputText, 'utf8');
28+
}, { ts });

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.