Use typings generated from JSON Schemas.#5662
Draft
iclanton wants to merge 40 commits intomicrosoft:mainfrom
Draft
Use typings generated from JSON Schemas.#5662iclanton wants to merge 40 commits intomicrosoft:mainfrom
iclanton wants to merge 40 commits intomicrosoft:mainfrom
Conversation
…n and typings-generator.
…a-typings-plugin-options.schema.json.
… generator test project's clean globs.
- Remove dTsFilesInputFolderName from DeepImportsPlugin config in rush-lib webpack - Update copyEmptyModules.js to only generate JS stubs without .d.ts copying - Refactor rush-sdk generate-stubs.ts to only create JS stubs - Add copy-files-plugin task to copy .d.ts files from rush-lib/lib-dts to rush-sdk/lib-dts - Declarations now live only in lib-dts, not duplicated in lib-commonjs
This reverts commit f8f628a.
37dc842 to
aa46a62
Compare
…word in strict mode AJV.
…tom keyword in strict mode AJV.
…tom keyword in strict mode AJV.
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.
Summary
Many Rush Stack packages define JSON Schemas for their config files and then maintain hand-written TypeScript interfaces to represent the same structure. This duplication leads to drift, missing documentation, and boilerplate. This PR integrates
@rushstack/heft-json-schema-typings-plugininto the monorepo's standard rigs so that TypeScript type declarations are automatically generated from JSON Schemas at build time, replacing hand-written interfaces across the repo.Here is a diff of the docs: iclanton/rushstack-docs-diff@405e303
Details
Rig integration:
@rushstack/heft-json-schema-typings-pluginas a build task inlocal-node-rig,local-web-rig, anddecoupled-local-node-rig. Schemas with.schema.jsonextension produce.schema.json.d.tsfiles intotemp/schema-ts(for compilation) andlib-dts(for publishing). The rigs also configurerootDirsso TypeScript can resolve the generated declarations alongside source files.Packages migrated to generated types (hand-written interfaces removed):
ICopyOperation,ICopyFilesPluginOptions,IDeleteOperation,IDeleteFilesPluginOptions,IRunScriptPluginOptions,ISetEnvironmentVariablesPluginOptions,IFileSelectionSpecifier, and all heft-plugin parameter typesIExperimentsJson,IApprovedPackagesJson,ICobuildJson,ICommonVersionsJson,IRushPluginsJson,IRushUserSettingsJson,ISubspacesJson, and othersICredentialCacheEntry,ICredentialCacheJsonIRigConfigJsonheft-plugins/*— 11 Heft plugins had their option interfaces replaced with schema-generated types (typescript, jest, lint, sass, storybook, api-extractor, webpack4/5, rspack, localization-typings, isolated-typescript-transpile)Schema improvements:
heft-plugin.schema.json,copy-files-options.schema.json,delete-files-options.schema.json,heft.schema.json) to JSON Schema draft-2019-09, using$defsandunevaluatedPropertiesfor cleaner type compositiontitlefields across all Rush schemas for consistent generated type namesdescriptionfields toapi-extractor.schema.jsondefinitions so generated types get proper JSDoc documentationfile-selection.schema.jsonfor reuse across copy/delete schemas-options.schema.jsonsuffix consistently@rushstack/node-core-librarychanges:'draft-2019-09'to theJsonSchemaVersiontype and implemented validation support usingajv/dist/2019@rushstack/heft-json-schema-typings-pluginchanges:@characters in generated JSDoc comments (e.g.,patternPropertieskeys like"^@[^\s]*$"are now wrapped in backtick code spans)Other:
.d.tsoutput fromlib-commonjstolib-dtsinrush-libandrush-sdkto align with the generated declarations workflowdecoupled-local-node-riguses a published version, so the regex fix isn't available yet)How it was tested
rush buildacross the repo and verified all affected projects compile successfully.schema.json.d.tsfiles match the expected types via snapshot tests inheft-json-schema-typings-plugin-test.api.mdreview files are updated correctly with no unexpected(undocumented)markersheft-plugin.schema.jsondraft-2019-09 upgrade withunevaluatedProperties: falsevalidates correctly at runtimeJsonSchemadraft-2019-09 support innode-core-libraryImpacted documentation
$schemain config files are unchanged, but the schema content itself is updated