Add Automated TypeScript Index Generation#20
Add Automated TypeScript Index Generation#20bawahakim wants to merge 3 commits intoThe-Commit-Company:mainfrom
Conversation
|
@nikkothari22 I've made the generate index option true by default, because I don't see any reason not to include indexes, but let me know if you think otherwise! |
|
I think it should be turned off by default because we generally avoid barrel imports in our codebase - it's a tiny bit faster to compile from what I've read online. The CLI should also respect the settings set in the DB unless overridden via a flag. |
|
Got it, I figured compile time doesn't matter much (especially if we're talking a few seconds), in contrast to keeping imports cleaner. In any case, will default it to false. The CLI uses a tertiary flag. If no flag is passed, it prioritizes the DB setting, otherwise defaults to true (I can also change that to false). When flag is passed, it takes precedence over DB setting (that's why there's |
Overview
This PR introduces automated generation of
index.tsfiles for TypeScript type definitions, allowing for easier and more maintainable imports across modules. It also adds user controls for this feature via both the settings UI and CLI, and provides robust test coverage for both the generator logic and the CLI commands.Key Features
1. Automated
index.tsGeneration{output_path}directory, anindex.tsis generated that re-exports all.tsfiles (excluding itself).index.tsis generated at:{output_path}/index.tsto re-export all module-level index files using namespace exports.
2. User Controls (Settings & CLI)
Settings Doctype
generate_indexes) checkbox to the App Type Generation Paths table in the Type Generation Settings doctype.CLI Flags
bench generate-types-for-doctypeandbench generate-types-for-modulenow accept--generate-indexes/--no-generate-indexesflags.3. Conditional Index Generation
4. Testing
Unit Test
test_type_generator.pyto verify correct creation of module and rootindex.tsfiles.bench run-testsrunner.How to Use
Enable/Disable index generation in the Type Generation Settings doctype per app.
Override via CLI: