Skip to content

Commit db06ae7

Browse files
committed
chore: fix type annotations
1 parent 32a07b3 commit db06ae7

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

packages/build-info/src/frameworks/framework.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type Detection = {
3333
accuracy: Accuracy
3434
/** The NPM package that was able to detect it (high accuracy) */
3535
package?: { name: string; version?: SemVer }
36-
packageJSON?: PackageJson
36+
packageJSON?: Partial<PackageJson>
3737
/** The absolute path to config file that is associated with the framework */
3838
config?: string
3939
/** The name of config file that is associated with the framework */
@@ -246,7 +246,9 @@ export abstract class BaseFramework implements Framework {
246246
}
247247

248248
/** check if the npmDependencies are used inside the provided package.json */
249-
private async npmDependenciesUsed(pkgJSON: PackageJson): Promise<{ name: string; version?: SemVer } | undefined> {
249+
private async npmDependenciesUsed(
250+
pkgJSON: Partial<PackageJson>,
251+
): Promise<{ name: string; version?: SemVer } | undefined> {
250252
const allDeps = [...Object.entries(pkgJSON.dependencies || {}), ...Object.entries(pkgJSON.devDependencies || {})]
251253

252254
const found = allDeps.find(([depName]) => this.npmDependencies.includes(depName))

packages/build-info/src/project.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class Project {
172172
}
173173

174174
/** retrieves the root package.json file */
175-
async getRootPackageJSON(): Promise<PackageJson> {
175+
async getRootPackageJSON(): Promise<Partial<PackageJson>> {
176176
// get the most upper json file
177177
const rootJSONPath = (
178178
await this.fs.findUpMultiple('package.json', { cwd: this.baseDirectory, stopAt: this.root })
@@ -185,17 +185,14 @@ export class Project {
185185
}
186186

187187
/** Retrieves the package.json and if one found with it's pkgPath */
188-
async getPackageJSON(startDirectory?: string): Promise<PackageJson & { pkgPath: string | null }> {
188+
async getPackageJSON(startDirectory?: string): Promise<Partial<PackageJson> & { pkgPath: string | null }> {
189189
const pkgPath = await this.fs.findUp('package.json', {
190190
cwd: startDirectory || this.baseDirectory,
191191
stopAt: this.root,
192192
})
193193
if (pkgPath) {
194194
const json = await this.fs.readJSON<PackageJson>(pkgPath)
195-
return {
196-
...json,
197-
pkgPath,
198-
}
195+
return Object.assign(json, { pkgPath })
199196
}
200197
return { pkgPath: null }
201198
}

packages/build-info/src/workspaces/detect-workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function detectPnpmWorkspaceGlobs(project: Project): Promise<string
5454
}
5555

5656
/** Get the workspace globs from the package.json file */
57-
export async function detectNpmOrYarnWorkspaceGlobs(pkgJSON: PackageJson): Promise<string[]> {
57+
export async function detectNpmOrYarnWorkspaceGlobs(pkgJSON: Partial<PackageJson>): Promise<string[]> {
5858
if (Array.isArray(pkgJSON.workspaces)) {
5959
return pkgJSON.workspaces || []
6060
}

0 commit comments

Comments
 (0)