@visulima/tsconfig 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## @visulima/tsconfig [3.2.0](https://github.com/visulima/visulima/compare/%40visulima%2Ftsconfig%403.1.1...%40visulima%2Ftsconfig%403.2.0) (2026-07-19)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/fs:** upgraded to 5.0.5
7
+
1
8
  ## @visulima/tsconfig [3.1.1](https://github.com/visulima/visulima/compare/%40visulima%2Ftsconfig%403.1.0...%40visulima%2Ftsconfig%403.1.1) (2026-07-17)
2
9
 
3
10
 
package/dist/index.d.ts CHANGED
@@ -72,26 +72,40 @@ type TsConfigResult = {
72
72
  */
73
73
  declare const findTsConfig: (cwd?: URL | string, options?: Options) => Promise<TsConfigResult>;
74
74
  declare const findTsConfigSync: (cwd?: URL | string, options?: Options) => TsConfigResult;
75
+ interface WriteTsConfigOptions extends WriteJsonOptions {
76
+ /** The directory to write the config into. Defaults to `process.cwd()`. */
77
+ cwd?: URL | string;
78
+ /**
79
+ * The file name to write. Defaults to `tsconfig.json`. Useful when emitting a derived project
80
+ * file (e.g. `tsconfig.build.json`) next to an existing config.
81
+ */
82
+ fileName?: string;
83
+ /**
84
+ * The TypeScript major version the written config targets. When set, compiler options removed in
85
+ * that version are dropped — e.g. `7` removes `baseUrl` so the config is accepted by the
86
+ * TypeScript 7 native compiler.
87
+ */
88
+ typescriptMajor?: number;
89
+ }
75
90
  /**
76
- * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig.json file.
91
+ * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig file.
92
+ *
93
+ * Numeric enum compiler options are normalized to their string names, so a resolved `CompilerOptions`
94
+ * object (e.g. from `readTsConfig`) can be written back to a valid config.
77
95
  * @param tsConfig The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.
78
- * @param options Optional. The write options and the current working directory. The type of `options` is an
79
- * intersection type of `WriteOptions` and a Record type with an optional `cwd` key of type `string`.
80
- * @returns A `Promise` that resolves when the tsconfig.json file has been written.
96
+ * @param options Optional. Write options plus the target directory (`cwd`), `fileName`, and `typescriptMajor`.
97
+ * @returns A `Promise` that resolves when the tsconfig file has been written.
81
98
  * The return type of function is `Promise&lt;void>`.
82
99
  */
83
- declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
84
- cwd?: URL | string;
85
- }) => Promise<void>;
100
+ declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteTsConfigOptions) => Promise<void>;
86
101
  /**
87
- * A function that writes the provided TypeScript configuration object to a tsconfig.json file.
102
+ * A function that writes the provided TypeScript configuration object to a tsconfig file.
103
+ *
104
+ * Numeric enum compiler options are normalized to their string names, so a resolved `CompilerOptions`
105
+ * object (e.g. from `readTsConfig`) can be written back to a valid config.
88
106
  * @param tsConfig The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.
89
- * @param options Optional. The write options and the current working directory. The type of `options` is an
90
- * intersection type of `WriteOptions` and a Record type with an optional `cwd` key of type `string`.
91
- * @returns A `Promise` that resolves when the tsconfig.json file has been written.
92
- * The return type of function is `Promise&lt;void>`.
107
+ * @param options Optional. Write options plus the target directory (`cwd`), `fileName`, and `typescriptMajor`.
108
+ * @returns Nothing.
93
109
  */
94
- declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
95
- cwd?: URL | string;
96
- }) => void;
97
- export { type Options as FindTsConfigOptions, type Options$1 as ReadTsConfigOptions, type TsConfigJsonResolved, type TsConfigResult, configDirectoryPlaceholder, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTsConfig, writeTsConfigSync };
110
+ declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteTsConfigOptions) => void;
111
+ export { type Options as FindTsConfigOptions, type Options$1 as ReadTsConfigOptions, type TsConfigJsonResolved, type TsConfigResult, type WriteTsConfigOptions, configDirectoryPlaceholder, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTsConfig, writeTsConfigSync };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{findTsConfig as r,findTsConfigSync as f}from"./packem_shared/findTsConfig-eQNXp6cy.js";import{configDirectoryPlaceholder as n,implicitBaseUrlSymbol as t,readTsConfig as c}from"./packem_shared/configDirectoryPlaceholder-BhSMyWHh.js";import{writeTsConfig as s,writeTsConfigSync as l}from"./packem_shared/writeTsConfig-BrUFAEe9.js";export{n as configDirectoryPlaceholder,r as findTsConfig,f as findTsConfigSync,t as implicitBaseUrlSymbol,c as readTsConfig,s as writeTsConfig,l as writeTsConfigSync};
1
+ import{findTsConfig as r,findTsConfigSync as f}from"./packem_shared/findTsConfig-eQNXp6cy.js";import{configDirectoryPlaceholder as n,implicitBaseUrlSymbol as t,readTsConfig as c}from"./packem_shared/configDirectoryPlaceholder-BhSMyWHh.js";import{writeTsConfig as s,writeTsConfigSync as l}from"./packem_shared/writeTsConfig-BfWYkL2f.js";export{n as configDirectoryPlaceholder,r as findTsConfig,f as findTsConfigSync,t as implicitBaseUrlSymbol,c as readTsConfig,s as writeTsConfig,l as writeTsConfigSync};
@@ -0,0 +1 @@
1
+ import{writeJson as l,writeJsonSync as f}from"@visulima/fs";import{toPath as m}from"@visulima/fs/utils";import{join as a}from"@visulima/path";const u={0:"es3",1:"es5",2:"es2015",3:"es2016",4:"es2017",5:"es2018",6:"es2019",7:"es2020",8:"es2021",9:"es2022",10:"es2023",11:"es2024",99:"esnext"},j={0:"none",1:"commonjs",2:"amd",3:"umd",4:"system",5:"es2015",6:"es2020",7:"es2022",99:"esnext",100:"node16",101:"node18",199:"nodenext",200:"preserve"},w={1:"classic",2:"node10",3:"node16",99:"nodenext",100:"bundler"},y={1:"preserve",2:"react-native",3:"react",4:"react-jsx",5:"react-jsxdev"},O={1:"legacy",2:"auto",3:"force"},x={0:"crlf",1:"lf"},v={jsx:y,module:j,moduleDetection:O,moduleResolution:w,newLine:x,target:u},S={7:new Set(["baseUrl","charset","importsNotUsedAsValues","keyofStringsOnly","noImplicitUseStrict","noStrictGenericChecks","out","prepend","preserveValueImports","suppressExcessPropertyErrors","suppressImplicitAnyIndexErrors"])},g=(e,n={})=>{const{removedForMajor:c}=n;let t;if(c!==void 0)for(const[s,o]of Object.entries(S))c>=Number(s)&&(t=t?new Set([...t,...o]):o);const r={...e};for(const[s,o]of Object.entries(e)){if(t?.has(s)){delete r[s];continue}const i=v[s];if(i&&typeof o=="number"){const p=i[o];p===void 0?delete r[s]:r[s]=p}}return r},d=(e,n)=>e.compilerOptions?{...e,compilerOptions:g(e.compilerOptions,{removedForMajor:n})}:e,I=async(e,n={})=>{const{cwd:c,fileName:t="tsconfig.json",typescriptMajor:r,...s}=n,o=m(c??process.cwd());await l(a(o,t),d(e,r),s)},C=(e,n={})=>{const{cwd:c,fileName:t="tsconfig.json",typescriptMajor:r,...s}=n,o=m(c??process.cwd());f(a(o,t),d(e,r),s)};export{I as writeTsConfig,C as writeTsConfigSync};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/tsconfig",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "Find and/or parse the tsconfig.json file from a directory path.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -52,7 +52,7 @@
52
52
  "provenance": true
53
53
  },
54
54
  "dependencies": {
55
- "@visulima/fs": "5.0.4",
55
+ "@visulima/fs": "5.0.5",
56
56
  "@visulima/path": "3.0.0",
57
57
  "jsonc-parser": "^3.3.1",
58
58
  "resolve-pkg-maps": "^1.0.0"
@@ -1 +0,0 @@
1
- import{writeJson as w,writeJsonSync as e}from"@visulima/fs";import{toPath as c}from"@visulima/fs/utils";import{join as r}from"@visulima/path";const a=async(o,s={})=>{const{cwd:n,...t}=s,i=c(n??process.cwd());await w(r(i,"tsconfig.json"),o,t)},d=(o,s={})=>{const{cwd:n,...t}=s,i=c(n??process.cwd());e(r(i,"tsconfig.json"),o,t)};export{a as writeTsConfig,d as writeTsConfigSync};