mirror of
https://github.com/discourse/discourse.git
synced 2026-08-04 10:39:43 +08:00
We've been using basic type-checking via JSDoc for some time. This commit allows us to author proper `.ts`/`.gts` files, and use the full typescript syntax. Initially, only d-button and a single chat file are migrated, as proof of functionality. In future, we may migrate more files, and consider making our tsconfig more strict.
26 lines
596 B
JavaScript
Vendored
26 lines
596 B
JavaScript
Vendored
import { Preprocessor } from "../content-tag";
|
|
|
|
const preprocessor = new Preprocessor();
|
|
|
|
export default function discourseGjs() {
|
|
return {
|
|
name: "discourse-gjs",
|
|
|
|
transform: {
|
|
// Enforce running the gjs transform before any others like babel that expect valid JS
|
|
order: "pre",
|
|
handler(input, id) {
|
|
if (!id.endsWith(".gjs") && !id.endsWith(".gts")) {
|
|
return null;
|
|
}
|
|
let { code, map } = preprocessor.process(input, {
|
|
filename: id,
|
|
});
|
|
return {
|
|
code,
|
|
map,
|
|
};
|
|
},
|
|
},
|
|
};
|
|
}
|