Repository navigation
fix: prevent SimpleFaker from loading Faker (AI benchmark) - #4225
Closed
Shinigami92 wants to merge 1 commit into
Closed
Shinigami92 wants to merge 1 commit into
Shinigami92 wants to merge 1 commit into
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #4225 +/- ##
=======================================
Coverage 99.18% 99.18%
=======================================
Files 1179 1182 +3
Lines 3947 3947
Branches 699 713 +14
=======================================
Hits 3915 3915
Misses 28 28
Partials 4 4
🚀 New features to boost your workflow:
|
Member
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR is a benchmark: it compares AI-generated work with human work. It is not meant to replace #4220 by @ST-DDT, which should stay the PR that gets merged. The goal is to compare both solutions and improve #4220 by taking the better parts of each.
How this was made
Claude Code got the same problem statement (the
simple-faker.ts -> location/module.ts -> location/city.ts -> faker.tsimport chain), but was not allowed to look at #4220, its branch, or any branch that already had the fix. The comparison below was written afterwards.Result
Both PRs chose the same approach: move each
Simple*Moduleinto its ownsimple-module.ts, keep only the full class inmodule.ts, pointsimple-faker.tsat the new files, and teachgenerate-module-tree.tsto handle both files.All production files except the three
index.tsfiles are byte-identical between the two PRs (simple-faker.ts, and both module files fordate,helpersandlocation). The PRs differ only in the re-exports, the generator internals and the tests.Comparison
index.tsre-exportsexport type { DateModule } from './module'+ same forSimpleDateModuleexport type * from './simple-module'export type *. #4220 is more explicitdirectory.getSourceFiles(['module.ts', 'simple-module.ts'])['simple-module.ts', 'module.ts']; still throws ifmodule.tsis missingmoduleFile.getFilePath()resolve(FILE_PATH_SRC, 'modules', moduleName, fileName)Simple${toPascalCase(moduleName)}Module, only when both files existsimple-module.tsFakerCoretype importhelpers-only patch, applied to both filespatchModuleImportsparamsfileName: string, added as the last parameterfileName: ModuleFileName(a literal union)vi.mock('../src/faker')for the whole file, plusvi.resetModules()and a dynamic importvi.doMockscoped to one test, plusvi.resetModules()anddoUnmockinfinallyImport chain: …from the static test onlysrc/simple-faker.ts, skippingimport typeThings worth taking into #4220
simple-module.tsinstead of building the name.FakerCoreas a normal type-import candidate and remove it from thehelperspatch.fileNameas'module.ts' | 'simple-module.ts'..tsand/index.tsonly).export type *(consistent) or named type exports (explicit) inindex.tsis a matter of preference.Things this PR should take from #4220: use
moduleFile.getFilePath()for the output path, and the stack-trace-based message in the runtime test.Process notes (AI side)
pnpm run preflight, type-checking failed because the simple helpers class lost itsFakerCoreimport (multiple()uses it). That's what led to the genericFakerCorehandling.🤖 Generated with Claude Code