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, Overwrite};
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 {
17            overwrite: Overwrite::IfMissing,
18            header: None,
19        }
20    }
21
22    fn render(&self) -> String {
23        r#"{
24  "compilerOptions": {
25    "lib": ["ESNext"],
26    "target": "ESNext",
27    "module": "ESNext",
28    "moduleDetection": "force",
29    "moduleResolution": "bundler",
30    "allowImportingTsExtensions": true,
31    "verbatimModuleSyntax": true,
32    "noEmit": true,
33    "strict": true,
34    "skipLibCheck": true,
35    "noFallthroughCasesInSwitch": true,
36    "noUnusedLocals": true,
37    "noUnusedParameters": true,
38    "noPropertyAccessFromIndexSignature": true,
39    "resolveJsonModule": true,
40    "esModuleInterop": true
41  },
42  "include": ["src/**/*.ts"]
43}
44"#
45        .to_string()
46    }
47}