Add one time prompt to try ts 7.0 if you have ts nightly installed#311977
Add one time prompt to try ts 7.0 if you have ts nightly installed#311977mjbvz merged 1 commit intomicrosoft:mainfrom
Conversation
Fixes microsoft#311966 Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Adds a one-time, experiment-gated notification in the TypeScript language features extension that prompts TypeScript Nightly users to try the “TypeScript 7 Native Preview” extension.
Changes:
- Introduces
suggestNativePreviewUI flow that detects TS Nightly, checks experiment enrollment, and offers Install / Learn More / Don’t Show Again. - Wires the prompt into extension activation after creating the experimentation service.
- Extends experimentation typings and adjusts treatment variable retrieval to fall back to the provided default when the variable is unset.
Show a summary per file
| File | Description |
|---|---|
| extensions/typescript-language-features/src/ui/suggestNativePreview.ts | New one-time prompt logic gated by TS Nightly presence and an experimentation treatment variable. |
| extensions/typescript-language-features/src/extension.ts | Instantiates the experimentation service and triggers the prompt during activation. |
| extensions/typescript-language-features/src/experimentationService.ts | Adds the new experiment variable type and refines treatment variable retrieval/defaulting. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 2
| try { | ||
| const treatmentVariable = experimentationService.getTreatmentVariableAsync('vscode', name, /*checkCache*/ true) as Promise<ExperimentTypes[K]>; | ||
| return treatmentVariable; | ||
| const treatmentVariable = await experimentationService.getTreatmentVariableAsync('vscode', name, /*checkCache*/ true) as ExperimentTypes[K]; |
There was a problem hiding this comment.
await experimentationService.getTreatmentVariableAsync(...) as ExperimentTypes[K] relies on await/type-assertion precedence and is easy to misread as asserting the Promise rather than the resolved value. Consider restructuring to await first and then apply the type assertion (or otherwise avoid the combined await ... as ... form) to keep the typing accurate and the intent clear.
| const treatmentVariable = await experimentationService.getTreatmentVariableAsync('vscode', name, /*checkCache*/ true) as ExperimentTypes[K]; | |
| const rawTreatmentVariable = await experimentationService.getTreatmentVariableAsync('vscode', name, /*checkCache*/ true); | |
| const treatmentVariable = rawTreatmentVariable as ExperimentTypes[K]; |
| // shared properties to the ExperimentationTelemetryReporter we just created. | ||
| new ExperimentationService(experimentTelemetryReporter, id, version, context.globalState); | ||
| const experimentationService = new ExperimentationService(experimentTelemetryReporter, id, version, context.globalState); | ||
| suggestNativePreview(context, experimentationService); |
There was a problem hiding this comment.
The call to suggestNativePreview returns a Promise but is neither awaited nor explicitly handled. This can lead to unhandled promise rejections during activation if the prompt/command throws. Consider either awaiting it (if activation should wait) or prefixing with void and adding internal error handling inside suggestNativePreview (e.g. a top-level try/catch) to ensure failures don’t surface as unhandled rejections.
| suggestNativePreview(context, experimentationService); | |
| void suggestNativePreview(context, experimentationService).catch(() => { | |
| // Ignore errors from this non-blocking suggestion flow during activation. | |
| }); |
Fixes #311966