GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TypeScript/scripts/checkModuleFormat.mjs at main · dbaeumer/TypeScript

Expand file tree

/

checkModuleFormat.mjs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
54 lines (48 loc) · 1.75 KB
/

checkModuleFormat.mjs

Copy path

File metadata and controls

54 lines (48 loc) · 1.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { createRequire } from "module";
import {
__importDefault,
__importStar,
} from "tslib";
import { pathToFileURL } from "url";
// This script tests that TypeScript's CJS API is structured
// as expected. It calls "require" as though it were in CWD,
// so it can be tested on a separate install of TypeScript.
const require = createRequire(process.cwd() + "/index.js");
const typescript = process.argv[2];
const resolvedTypeScript = pathToFileURL(require.resolve(typescript)).toString();
console.log(`Testing ${typescript}...`);
// See: https://github.com/microsoft/TypeScript/pull/51474#issuecomment-1310871623
/** @type {[fn: (() => Promise<any>), shouldSucceed: boolean][]} */
const fns = [
[() => require(typescript).version, true],
[() => require(typescript).default.version, false],
[() => __importDefault(require(typescript)).version, false],
[() => __importDefault(require(typescript)).default.version, true],
[() => __importStar(require(typescript)).version, true],
[() => __importStar(require(typescript)).default.version, true],
[async () => (await import(resolvedTypeScript)).version, true],
[async () => (await import(resolvedTypeScript)).default.version, true],
];
for (const [fn, shouldSucceed] of fns) {
let success = false;
try {
success = !!(await fn());
}
catch {
// Ignore
}
const status = success ? "succeeded" : "failed";
if (success === shouldSucceed) {
console.log(`${fn.toString()} ${status} as expected.`);
}
else {
console.log(`${fn.toString()} unexpectedly ${status}.`);
process.exitCode = 1;
}
}
if (process.exitCode) {
console.log("fail");
}
else {
console.log("ok");
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.