diff --git a/docs/api.md b/docs/api.md index 7ab1564..1573f8a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -17,7 +17,7 @@ export function find(filename: string, options?: TSConfckFindOptions | undefined #### TSConfckFindOptions ```ts -interface TSConfckFindOptions { +export interface TSConfckFindOptions { /** * A cache to improve performance for multiple calls in the same project * @@ -67,7 +67,7 @@ export function parse(filename: string, options?: TSConfckParseOptions | undefin #### TSConfckParseOptions ```ts -interface TSConfckParseOptions extends TSConfckFindOptions { +export interface TSConfckParseOptions extends TSConfckFindOptions { // same as find options } ``` @@ -75,7 +75,7 @@ interface TSConfckParseOptions extends TSConfckFindOptions { #### TSConfckParseResult ```ts -interface TSConfckParseResult { +export interface TSConfckParseResult { /** * absolute path to parsed tsconfig.json */ @@ -164,7 +164,7 @@ export function parseNative(filename: string, options?: TSConfckParseNativeOptio #### TSConfckParseNativeOptions ```ts -interface TSConfckParseNativeOptions extends TSConfckParseOptions { +export interface TSConfckParseNativeOptions extends TSConfckParseOptions { /** * Set this option to true to force typescript to ignore all source files. * @@ -180,7 +180,7 @@ interface TSConfckParseNativeOptions extends TSConfckParseOptions { #### TSConfckParseNativeResult ```ts -interface TSConfckParseNativeResult { +export interface TSConfckParseNativeResult { /** * absolute path to parsed tsconfig.json */ @@ -254,7 +254,7 @@ export function findAll(dir: string, options?: TSConfckFindAllOptions | undefine #### TSConfckFindAllOptions ```ts -interface TSConfckFindAllOptions { +export interface TSConfckFindAllOptions { /** * helper to skip subdirectories when scanning for tsconfig.json * diff --git a/package.json b/package.json index 33a0bb8..3b88370 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "format": "pnpm check:format --write", "fixup": "run-s generate lint format", "generate": "run-s generate:types generate:docs", - "generate:types": "pnpm --dir packages/tsconfck run dts-buddy", + "generate:types": "pnpm --dir packages/tsconfck run dts-buddy -m tsconfck:src/public.d.ts", "generate:docs": "node scripts/generate-api-docs.js", "release": "pnpm changeset publish", "prepare": "husky", @@ -23,7 +23,7 @@ "@changesets/cli": "^2.27.7", "@eslint/js": "^9.9.0", "@svitejs/changesets-changelog-github-compact": "^1.1.0", - "dts-buddy": "^0.4.7", + "dts-buddy": "^0.5.3", "esbuild": "^0.23.1", "eslint": "^9.9.0", "eslint-config-prettier": "^9.1.0", diff --git a/packages/tsconfck/src/public.d.ts b/packages/tsconfck/src/public.d.ts index a0be253..b29ef1a 100644 --- a/packages/tsconfck/src/public.d.ts +++ b/packages/tsconfck/src/public.d.ts @@ -120,3 +120,6 @@ export interface TSConfckParseNativeResult { */ result: any; } + +// eslint-disable-next-line n/no-missing-import +export * from './index.js'; diff --git a/packages/tsconfck/types/index.d.ts b/packages/tsconfck/types/index.d.ts index e739429..b43f26d 100644 --- a/packages/tsconfck/types/index.d.ts +++ b/packages/tsconfck/types/index.d.ts @@ -1,141 +1,5 @@ declare module 'tsconfck' { - /** - * find the closest tsconfig.json file - * - * @param filename - path to file to find tsconfig for (absolute or relative to cwd) - * @param options - options - * @returns absolute path to closest tsconfig.json or null if not found - */ - export function find(filename: string, options?: TSConfckFindOptions | undefined): Promise; - /** - * find all tsconfig.json files in dir - * - * @param dir - path to dir (absolute or relative to cwd) - * @param options - options - * @returns list of absolute paths to all found tsconfig.json files - */ - export function findAll(dir: string, options?: TSConfckFindAllOptions | undefined): Promise; - /** - * convert content of tsconfig.json to regular json - * - * @param tsconfigJson - content of tsconfig.json - * @returns content as regular json, comments and dangling commas have been replaced with whitespace - */ - export function toJson(tsconfigJson: string): string; - /** - * find the closest tsconfig.json file using native ts.findConfigFile - * - * You must have `typescript` installed to use this - * - * @param filename - path to file to find tsconfig for (absolute or relative to cwd) - * @param options - options - * @returns absolute path to closest tsconfig.json - */ - export function findNative(filename: string, options?: TSConfckFindOptions | undefined): Promise; - export class TSConfckCache { - /** - * clear cache, use this if you have a long running process and tsconfig files have been added,changed or deleted - */ - clear(): void; - /** - * has cached closest config for files in dir - * */ - hasConfigPath(dir: string, configName?: string | undefined): boolean; - /** - * get cached closest tsconfig for files in dir - * @throws {unknown} if cached value is an error - */ - getConfigPath(dir: string, configName?: string | undefined): Promise | string | null; - /** - * has parsed tsconfig for file - * */ - hasParseResult(file: string): boolean; - /** - * get parsed tsconfig for file - * @throws {unknown} if cached value is an error - */ - getParseResult(file: string): Promise | T; - /** - * @param isRootFile a flag to check if current file which involking the parse() api, used to distinguish the normal cache which only parsed by parseFile() - * */ - private setParseResult; - - private setConfigPath; - #private; - } - /** - * parse the closest tsconfig.json file - * - * @param filename - path to a tsconfig .json or a source file or directory (absolute or relative to cwd) - * @param options - options - * */ - export function parse(filename: string, options?: TSConfckParseOptions | undefined): Promise; - export class TSConfckParseError extends Error { - /** - * - * @param message - error message - * @param code - error code - * @param tsconfigFile - path to tsconfig file - * @param cause - cause of this error - */ - constructor(message: string, code: string, tsconfigFile: string, cause: Error | null); - /** - * error code - * */ - code: string; - /** - * error cause - * */ - cause: Error | undefined; - /** - * absolute path of tsconfig file where the error happened - * */ - tsconfigFile: string; - } - /** - * parse the closest tsconfig.json file with typescript native functions - * - * You need to have `typescript` installed to use this - * - * @param filename - path to a tsconfig .json or a source file (absolute or relative to cwd) - * @param options - options - * */ - export function parseNative(filename: string, options?: TSConfckParseNativeOptions | undefined): Promise; - export class TSConfckParseNativeError extends Error { - /** - * - * @param diagnostic - diagnostics of ts - * @param tsconfigFile - file that errored - * @param result - parsed result, if any - */ - constructor(diagnostic: TSDiagnosticError, tsconfigFile: string, result: any | null); - /** - * code of typescript diagnostic, prefixed with "TS " - * */ - code: string; - /** - * full ts diagnostic that caused this error - * */ - diagnostic: TSDiagnosticError; - /** - * native result if present, contains all errors in result.errors - * */ - result: any | undefined; - /** - * absolute path of tsconfig file where the error happened - * */ - tsconfigFile: string; - } - /** - * { - * code: number; - * category: number; - * messageText: string; - * start?: number; - * } TSDiagnosticError - */ - type TSDiagnosticError = any; - interface TSConfckFindOptions { + export interface TSConfckFindOptions { /** * A cache to improve performance for multiple calls in the same project * @@ -169,11 +33,11 @@ declare module 'tsconfck' { configName?: string; } - interface TSConfckParseOptions extends TSConfckFindOptions { + export interface TSConfckParseOptions extends TSConfckFindOptions { // same as find options } - interface TSConfckFindAllOptions { + export interface TSConfckFindAllOptions { /** * helper to skip subdirectories when scanning for tsconfig.json * @@ -188,7 +52,7 @@ declare module 'tsconfck' { configNames?: string[]; } - interface TSConfckParseResult { + export interface TSConfckParseResult { /** * absolute path to parsed tsconfig.json */ @@ -217,7 +81,7 @@ declare module 'tsconfck' { extended?: TSConfckParseResult[]; } - interface TSConfckParseNativeOptions extends TSConfckParseOptions { + export interface TSConfckParseNativeOptions extends TSConfckParseOptions { /** * Set this option to true to force typescript to ignore all source files. * @@ -229,7 +93,7 @@ declare module 'tsconfck' { ignoreSourceFiles?: boolean; } - interface TSConfckParseNativeResult { + export interface TSConfckParseNativeResult { /** * absolute path to parsed tsconfig.json */ @@ -255,6 +119,144 @@ declare module 'tsconfck' { */ result: any; } + export class TSConfckCache { + /** + * clear cache, use this if you have a long running process and tsconfig files have been added,changed or deleted + */ + clear(): void; + /** + * has cached closest config for files in dir + * */ + hasConfigPath(dir: string, configName?: string | undefined): boolean; + /** + * get cached closest tsconfig for files in dir + * @throws {unknown} if cached value is an error + */ + getConfigPath(dir: string, configName?: string | undefined): Promise | string | null; + /** + * has parsed tsconfig for file + * */ + hasParseResult(file: string): boolean; + /** + * get parsed tsconfig for file + * @throws {unknown} if cached value is an error + */ + getParseResult(file: string): Promise | T; + /** + * @param isRootFile a flag to check if current file which involking the parse() api, used to distinguish the normal cache which only parsed by parseFile() + * */ + private setParseResult; + + private setConfigPath; + #private; + } + /** + * find the closest tsconfig.json file + * + * @param filename - path to file to find tsconfig for (absolute or relative to cwd) + * @param options - options + * @returns absolute path to closest tsconfig.json or null if not found + */ + export function find(filename: string, options?: TSConfckFindOptions | undefined): Promise; + /** + * find all tsconfig.json files in dir + * + * @param dir - path to dir (absolute or relative to cwd) + * @param options - options + * @returns list of absolute paths to all found tsconfig.json files + */ + export function findAll(dir: string, options?: TSConfckFindAllOptions | undefined): Promise; + /** + * convert content of tsconfig.json to regular json + * + * @param tsconfigJson - content of tsconfig.json + * @returns content as regular json, comments and dangling commas have been replaced with whitespace + */ + export function toJson(tsconfigJson: string): string; + /** + * find the closest tsconfig.json file using native ts.findConfigFile + * + * You must have `typescript` installed to use this + * + * @param filename - path to file to find tsconfig for (absolute or relative to cwd) + * @param options - options + * @returns absolute path to closest tsconfig.json + */ + export function findNative(filename: string, options?: TSConfckFindOptions | undefined): Promise; + /** + * parse the closest tsconfig.json file + * + * @param filename - path to a tsconfig .json or a source file or directory (absolute or relative to cwd) + * @param options - options + * */ + export function parse(filename: string, options?: TSConfckParseOptions | undefined): Promise; + export class TSConfckParseError extends Error { + /** + * + * @param message - error message + * @param code - error code + * @param tsconfigFile - path to tsconfig file + * @param cause - cause of this error + */ + constructor(message: string, code: string, tsconfigFile: string, cause: Error | null); + /** + * error code + * */ + code: string; + /** + * error cause + * */ + cause: Error | undefined; + /** + * absolute path of tsconfig file where the error happened + * */ + tsconfigFile: string; + } + /** + * parse the closest tsconfig.json file with typescript native functions + * + * You need to have `typescript` installed to use this + * + * @param filename - path to a tsconfig .json or a source file (absolute or relative to cwd) + * @param options - options + * */ + export function parseNative(filename: string, options?: TSConfckParseNativeOptions | undefined): Promise; + export class TSConfckParseNativeError extends Error { + /** + * + * @param diagnostic - diagnostics of ts + * @param tsconfigFile - file that errored + * @param result - parsed result, if any + */ + constructor(diagnostic: TSDiagnosticError, tsconfigFile: string, result: any | null); + /** + * code of typescript diagnostic, prefixed with "TS " + * */ + code: string; + /** + * full ts diagnostic that caused this error + * */ + diagnostic: TSDiagnosticError; + /** + * native result if present, contains all errors in result.errors + * */ + result: any | undefined; + /** + * absolute path of tsconfig file where the error happened + * */ + tsconfigFile: string; + } + /** + * { + * code: number; + * category: number; + * messageText: string; + * start?: number; + * } TSDiagnosticError + */ + type TSDiagnosticError = any; + + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/packages/tsconfck/types/index.d.ts.map b/packages/tsconfck/types/index.d.ts.map index 8a81d5d..0e22aee 100644 --- a/packages/tsconfck/types/index.d.ts.map +++ b/packages/tsconfck/types/index.d.ts.map @@ -2,33 +2,33 @@ "version": 3, "file": "index.d.ts", "names": [ + "TSConfckFindOptions", + "TSConfckParseOptions", + "TSConfckFindAllOptions", + "TSConfckParseResult", + "TSConfckParseNativeOptions", + "TSConfckParseNativeResult", + "TSConfckCache", "find", "findAll", "toJson", "findNative", - "TSConfckCache", "parse", "TSConfckParseError", "parseNative", "TSConfckParseNativeError", - "TSDiagnosticError", - "TSConfckFindOptions", - "TSConfckParseOptions", - "TSConfckFindAllOptions", - "TSConfckParseResult", - "TSConfckParseNativeOptions", - "TSConfckParseNativeResult" + "TSDiagnosticError" ], "sources": [ + "../src/public.d.ts", + "../src/cache.js", "../src/find.js", "../src/find-all.js", "../src/to-json.js", "../src/find-native.js", - "../src/cache.js", "../src/parse.js", "../src/parse-native.js", - "../src/parse-native.d.ts", - "../src/public.d.ts" + "../src/parse-native.d.ts" ], "sourcesContent": [ null, @@ -41,6 +41,6 @@ null, null ], - "mappings": ";;;;;;;;iBAUsBA,IAAIA;;;;;;;;iBCYJC,OAAOA;;;;;;;iBCTbC,MAAMA;;;;;;;;;;iBCDAC,UAAUA;cCXnBC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC2BJC,KAAKA;cA6VdC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC7VTC,WAAWA;cAkOpBC,wBAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MC9MzBC,iBAAiBA;WC9CZC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAkCnBC,oBAAoBA;;;;WAIpBC,sBAAsBA;;;;;;;;;;;;;;;WAetBC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6BnBC,0BAA0BA;;;;;;;;;;;;WAY1BC,yBAAyBA", + "mappings": ";kBAEiBA,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkCnBC,oBAAoBA;;;;kBAIpBC,sBAAsBA;;;;;;;;;;;;;;;kBAetBC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6BnBC,0BAA0BA;;;;;;;;;;;;kBAY1BC,yBAAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;cC/F7BC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCSJC,IAAIA;;;;;;;;iBCYJC,OAAOA;;;;;;;iBCTbC,MAAMA;;;;;;;;;;iBCDAC,UAAUA;;;;;;;iBCgBVC,KAAKA;cA6VdC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC7VTC,WAAWA;cAkOpBC,wBAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MC9MzBC,iBAAiBA", "ignoreList": [] } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7b5baf4..39ce075 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: specifier: ^1.1.0 version: 1.1.0 dts-buddy: - specifier: ^0.4.7 - version: 0.4.7(typescript@5.5.4) + specifier: ^0.5.3 + version: 0.5.3(typescript@5.5.4) esbuild: specifier: ^0.23.1 version: 0.23.1 @@ -872,11 +872,11 @@ packages: resolution: {integrity: sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==} engines: {node: '>=12'} - dts-buddy@0.4.7: - resolution: {integrity: sha512-trSY5EWkWWKov9uf9nTPjmEoiIcrYPpNEVCu75drPX9Fus3OwQzN/WNXyO+w7cMteBrUqSoExAAud1KCzYv0SQ==} + dts-buddy@0.5.3: + resolution: {integrity: sha512-wS2DC5T+F6R+sG/YNlJ21yn8CKVhy1QQlpKA34G+uO4PUXkwz+JQWbGcIryUByxoJgbH98O0dTGzE2RqsRR3KA==} hasBin: true peerDependencies: - typescript: '>=5.0.4 <5.5' + typescript: '>=5.0.4 <5.6' eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} @@ -2691,7 +2691,7 @@ snapshots: dotenv@16.4.1: {} - dts-buddy@0.4.7(typescript@5.5.4): + dts-buddy@0.5.3(typescript@5.5.4): dependencies: '@jridgewell/source-map': 0.3.6 '@jridgewell/sourcemap-codec': 1.4.15