-
Notifications
You must be signed in to change notification settings - Fork 5
TypeScript #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Support for transpiled languages can be achieved by providing appropriate import run from "https://deno.land/x/replete/run.js";
import typescript from "https://esm.sh/typescript";
function compile_typescript(source) {
return typescript.transpileModule(
source,
{
compilerOptions: {
module: typescript.ModuleKind.ES2015,
newLine: "lf"
}
}
).outputText;
}
run({
command(message) {
if (message.locator !== undefined && message.locator.endsWith(".ts")) {
message.source = compile_typescript(message.source);
}
return Promise.resolve(message);
},
read(locator) {
return Deno.readFile(new URL(locator)).then(function (buffer) {
return (
locator.endsWith(".ts")
? compile_typescript(new TextDecoder().decode(buffer))
: buffer
);
});
},
headers(locator) {
if (locator.endsWith(".js") || locator.endsWith(".ts")) {
return {"Content-Type": "text/javascript"};
}
}
}); Or, equivalently, use this {
"command": [
"deno",
"run",
"--allow-all",
"--importmap",
"https://deno.land/x/replete/import_map.json",
"https://gist.githubusercontent.com/jamesdiacono/b260251fdb8e4d00dacc40d78ae16c31/raw/b1c52a46c332cce579da40b79ab2e660a7f13be3/replete_typescript.js"
]
} |
I don't see a
|
Replete does not include TypeScript, or any other transpilers. You are expected to bring your own. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd like to be able to evaluate TS files without manually removing type annotations.
The text was updated successfully, but these errors were encountered: