Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Prettify Typescript code

const pretty = await @pomdtr.prettifyTS("const hello='Hello world'")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export async function prettifyTS(code: string) {
const prettier = await import(
"https://unpkg.com/prettier@3.0.1/standalone.mjs"
);
const prettierPluginTypescript = await import(
"https://unpkg.com/prettier@3.0.1/plugins/typescript.mjs"
);
const prettierPluginEstree = await import(
"https://unpkg.com/prettier@3.0.1/plugins/estree.mjs"
);
return prettier.format(code, {
parser: "typescript",
plugins: [prettierPluginTypescript, prettierPluginEstree],
});
}
October 23, 2023