-
Notifications
You must be signed in to change notification settings - Fork 36.6k
Try generate ITerminalConfiguration type via JSON schema #273640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR explores generating a TypeScript type ITerminalConfiguration2 automatically from the terminal configuration JSON schema, eliminating the need to manually maintain a separate type definition. The approach uses the TypeFromJsonSchema utility type to derive types from the configuration schema at compile time.
Key changes:
- Adds
TypeFromJsonSchemaimport from the JSON schema utilities - Converts
terminalConfigurationto useas const satisfiespattern to preserve literal types - Creates
ITerminalConfiguration2type that derives types from the schema with key transformation
| const terminalConfiguration = terminalConfigurationConst as IStringDictionary<IConfigurationPropertySchema>; | ||
|
|
||
| export type ITerminalConfiguration2 = { | ||
| // [K in keyof typeof terminalConfiguration]: TypeFromJsonSchema<typeof terminalConfiguration[K]> |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type definition contains a commented-out alternative implementation on line 668. This commented code should be removed to keep the codebase clean, or if it represents a different approach worth preserving, it should be documented why both versions are present.
| // [K in keyof typeof terminalConfiguration]: TypeFromJsonSchema<typeof terminalConfiguration[K]> |
| // const b = { | ||
| // markdownDescription: localize('terminal.integrated.persistentSessionReviveProcess', "When the terminal process must be shut down (for example on window or application close), this determines when the previous terminal session contents/history should be restored and processes be recreated when the workspace is next opened.\n\nCaveats:\n\n- Restoring of the process current working directory depends on whether it is supported by the shell.\n- Time to persist the session during shutdown is limited, so it may be aborted when using high-latency remote connections."), | ||
| // type: 'string', | ||
| // enum: ['onExit', 'onExitAndWindowClose', 'never'], | ||
| // markdownEnumDescriptions: [ | ||
| // localize('terminal.integrated.persistentSessionReviveProcess.onExit', "Revive the processes after the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu)."), | ||
| // localize('terminal.integrated.persistentSessionReviveProcess.onExitAndWindowClose', "Revive the processes after the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu), or when the window is closed."), | ||
| // localize('terminal.integrated.persistentSessionReviveProcess.never', "Never restore the terminal buffers or recreate the process.") | ||
| // ], | ||
| // default: 'onExit' | ||
| // } as const satisfies IConfigurationPropertySchema;, | ||
|
|
||
| // type A = TypeFromJsonSchema<typeof b>; | ||
|
|
||
| // const a: A; | ||
|
|
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this commented-out test/debugging code (lines 672-697). This appears to be exploratory code used during development that should not be committed to the codebase.
| // const b = { | |
| // markdownDescription: localize('terminal.integrated.persistentSessionReviveProcess', "When the terminal process must be shut down (for example on window or application close), this determines when the previous terminal session contents/history should be restored and processes be recreated when the workspace is next opened.\n\nCaveats:\n\n- Restoring of the process current working directory depends on whether it is supported by the shell.\n- Time to persist the session during shutdown is limited, so it may be aborted when using high-latency remote connections."), | |
| // type: 'string', | |
| // enum: ['onExit', 'onExitAndWindowClose', 'never'], | |
| // markdownEnumDescriptions: [ | |
| // localize('terminal.integrated.persistentSessionReviveProcess.onExit', "Revive the processes after the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu)."), | |
| // localize('terminal.integrated.persistentSessionReviveProcess.onExitAndWindowClose', "Revive the processes after the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu), or when the window is closed."), | |
| // localize('terminal.integrated.persistentSessionReviveProcess.never', "Never restore the terminal buffers or recreate the process.") | |
| // ], | |
| // default: 'onExit' | |
| // } as const satisfies IConfigurationPropertySchema;, | |
| // type A = TypeFromJsonSchema<typeof b>; | |
| // const a: A; |
|
To re-evaluate during a debt week |
|
While this is cool, the types are getting a little too complex for comfort |
No description provided.