deno-musings/index.html

55 lines
1.5 KiB
HTML
Raw Normal View History

2024-10-12 12:28:41 -04:00
<script>
globalThis.Listen = [];
</script>
2024-10-10 10:00:12 -04:00
<script type="module" src="test_receiver.mjs"></script>
2024-10-12 12:28:41 -04:00
<!-- if test_rand.mjs exports a random number as default, there will be 4 different values if there is a cachebust on the import
2024-10-10 10:00:12 -04:00
<script type="module">
import r1 from "./test_rand.mjs?1";
import r2 from "./test_rand.mjs?2";
import r3 from "./test_rand.mjs?3";
import r4 from "./test_rand.mjs?4";
console.log(r1, r2, r3, r4);
2024-10-11 13:04:47 -04:00
</script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/typescript/4.5.4/typescript.min.js"></script>
<script type="module">
// TypeScript source code
const source = `
export const num: number = 42;
export function greet() {
console.log('Hello, world!');
}
`;
// Transpile the TypeScript code to JavaScript
const result = ts.transpileModule(source, {
compilerOptions: {
module: ts.ModuleKind.ESNext,
target: ts.ScriptTarget.ESNext
}
});
// Parse the AST of the TypeScript source code
const sourceFile = ts.createSourceFile('module.ts', source, ts.ScriptTarget.ESNext, true);
// Function to inspect the AST and find export declarations
function findExports(node) {
if (ts.isExportDeclaration(node) || ts.isExportAssignment(node)) {
console.log('Export found:', node);
}
ts.forEachChild(node, findExports);
}
// Traverse the AST
//findExports(sourceFile);
console.log(sourceFile);
// Output: export const num = 42; export function greet() { console.log('Hello, world!'); }
2024-10-10 10:00:12 -04:00
</script>