baobao_codegen_typescript/files/
tsconfig.rs

1//! tsconfig.json generator for TypeScript projects.
2
3use std::path::{Path, PathBuf};
4
5use baobao_core::{FileRules, GeneratedFile};
6
7/// The tsconfig.json configuration file.
8pub struct TsConfig;
9
10impl GeneratedFile for TsConfig {
11    fn path(&self, base: &Path) -> PathBuf {
12        base.join("tsconfig.json")
13    }
14
15    fn rules(&self) -> FileRules {
16        FileRules::create_once()
17    }
18
19    fn render(&self) -> String {
20        r#"{
21  "compilerOptions": {
22    "lib": ["ESNext"],
23    "target": "ESNext",
24    "module": "ESNext",
25    "moduleDetection": "force",
26    "moduleResolution": "bundler",
27    "allowImportingTsExtensions": true,
28    "verbatimModuleSyntax": true,
29    "noEmit": true,
30    "strict": true,
31    "skipLibCheck": true,
32    "noFallthroughCasesInSwitch": true,
33    "noUnusedLocals": true,
34    "noUnusedParameters": true,
35    "noPropertyAccessFromIndexSignature": true,
36    "resolveJsonModule": true,
37    "esModuleInterop": true
38  },
39  "include": ["src/**/*.ts"]
40}
41"#
42        .to_string()
43    }
44}