Towards useDefineForClassFields (#248695)

* final init order fixes https://github.com/microsoft/vscode/issues/243049

* a few more fixed when compiling with `"useDefineForClassFields": true`

https://github.com/microsoft/vscode/issues/243049 and https://github.com/microsoft/vscode/issues/186726

* add a dry-check that ensures we can/could compile/emit with explicitly defined class fields

https://github.com/microsoft/vscode/issues/186726
This commit is contained in:
Johannes Rieken
2025-05-12 11:46:15 +02:00
committed by GitHub
parent 9d06263000
commit 505092bbf7
15 changed files with 27 additions and 42 deletions

View File

@@ -123,8 +123,8 @@ jobs:
- name: Run Valid Layers Checks
run: npm run valid-layers-check
- name: Run Property Init Order Checks
run: npm run property-init-order-check
- name: Run Define Class Fields Checks
run: npm run define-class-fields-check
- name: Compile /build/
run: npm run compile

View File

@@ -308,8 +308,8 @@ jobs:
- name: Run Valid Layers Checks
run: npm run valid-layers-check
- name: Run Property Init Order Checks
run: npm run property-init-order-check
- name: Run Define Class Fields Checks
run: npm run define-class-fields-check
- name: Compile /build/
run: npm run compile

View File

@@ -104,12 +104,12 @@ steps:
- template: common/install-builtin-extensions.yml@self
- ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}:
- script: npm exec -- npm-run-all -lp core-ci-pr extensions-ci-pr hygiene eslint valid-layers-check property-init-order-check vscode-dts-compile-check tsec-compile-check
- script: npm exec -- npm-run-all -lp core-ci-pr extensions-ci-pr hygiene eslint valid-layers-check define-class-fields-check vscode-dts-compile-check tsec-compile-check
env:
GITHUB_TOKEN: "$(github-distro-mixin-password)"
displayName: Compile & Hygiene (OSS)
- ${{ else }}:
- script: npm exec -- npm-run-all -lp core-ci extensions-ci hygiene eslint valid-layers-check property-init-order-check vscode-dts-compile-check tsec-compile-check
- script: npm exec -- npm-run-all -lp core-ci extensions-ci hygiene eslint valid-layers-check define-class-fields-check vscode-dts-compile-check tsec-compile-check
env:
GITHUB_TOKEN: "$(github-distro-mixin-password)"
displayName: Compile & Hygiene (non-OSS)

View File

@@ -53,13 +53,6 @@ const TS_CONFIG_PATH = path.join(__dirname, '../../', 'src', 'tsconfig.json');
//
// #############################################################################################
//
const ignored = new Set([
'vs/editor/browser/view/viewLayer.ts',
'vs/platform/accessibilitySignal/browser/accessibilitySignalService.ts',
'vs/editor/contrib/inlayHints/browser/inlayHintsController.ts',
'vs/workbench/contrib/editSessions/browser/editSessionsStorageService.ts',
'vs/workbench/api/common/extHostLanguageFeatures.ts',
]);
const cancellationToken = {
isCancellationRequested: () => false,
throwIfCancellationRequested: () => { },
@@ -79,10 +72,6 @@ for (const file of program.getSourceFiles()) {
if (!file || file.isDeclarationFile) {
continue;
}
const relativePath = path.relative(path.dirname(TS_CONFIG_PATH), file.fileName).replace(/\\/g, '/');
if (ignored.has(relativePath)) {
continue;
}
visit(file);
}
if (seenFiles.size) {

View File

@@ -22,13 +22,6 @@ const TS_CONFIG_PATH = path.join(__dirname, '../../', 'src', 'tsconfig.json');
// #############################################################################################
//
const ignored = new Set([
'vs/editor/browser/view/viewLayer.ts',
'vs/platform/accessibilitySignal/browser/accessibilitySignalService.ts',
'vs/editor/contrib/inlayHints/browser/inlayHintsController.ts',
'vs/workbench/contrib/editSessions/browser/editSessionsStorageService.ts',
'vs/workbench/api/common/extHostLanguageFeatures.ts',
]);
const cancellationToken: ts.CancellationToken = {
isCancellationRequested: () => false,
@@ -59,12 +52,6 @@ for (const file of program.getSourceFiles()) {
if (!file || file.isDeclarationFile) {
continue;
}
const relativePath = path.relative(path.dirname(TS_CONFIG_PATH), file.fileName).replace(/\\/g, '/');
if (ignored.has(relativePath)) {
continue;
}
visit(file);
}

View File

@@ -45,7 +45,7 @@
"tsec-compile-check": "node node_modules/tsec/bin/tsec -p src/tsconfig.tsec.json",
"vscode-dts-compile-check": "tsc -p src/tsconfig.vscode-dts.json && tsc -p src/tsconfig.vscode-proposed-dts.json",
"valid-layers-check": "node build/lib/layersChecker.js",
"property-init-order-check": "node build/lib/propertyInitOrderChecker.js",
"define-class-fields-check": "node build/lib/propertyInitOrderChecker.js && tsc -p src/tsconfig.defineClassFields.json",
"update-distro": "node build/npm/update-distro.mjs",
"web": "echo 'npm run web' is replaced by './scripts/code-server' or './scripts/code-web'",
"compile-cli": "gulp compile-cli",

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"useDefineForClassFields": true,
"noEmit": true,
"skipLibCheck": true
}
}

View File

@@ -60,7 +60,7 @@ const newCommands: ApiCommand[] = [
range!: vscode.Range;
selectionRange!: vscode.Range;
children!: vscode.DocumentSymbol[];
override containerName!: string;
override containerName: string = '';
}
return value.map(MergedInfo.to);

View File

@@ -63,7 +63,7 @@ export interface IExtHostDebugService extends ExtHostDebugServiceShape {
export abstract class ExtHostDebugServiceBase extends DisposableCls implements IExtHostDebugService, ExtHostDebugServiceShape {
readonly _serviceBrand: undefined;
declare readonly _serviceBrand: undefined;
private _configProviderHandleCounter: number;
private _configProviders: ConfigProviderTuple[];

View File

@@ -1335,7 +1335,7 @@ class InlineCompletionAdapter {
items: readonly vscode.InlineCompletionItem[];
}>();
private readonly _isAdditionsProposedApiEnabled = isProposedApiEnabled(this._extension, 'inlineCompletionsAdditions');
private readonly _isAdditionsProposedApiEnabled: boolean;
constructor(
private readonly _extension: IExtensionDescription,
@@ -1343,6 +1343,7 @@ class InlineCompletionAdapter {
private readonly _provider: vscode.InlineCompletionItemProvider,
private readonly _commands: CommandsConverter,
) {
this._isAdditionsProposedApiEnabled = isProposedApiEnabled(this._extension, 'inlineCompletionsAdditions');
}
public get supportsHandleEvents(): boolean {

View File

@@ -31,8 +31,6 @@ import { IExtHostTerminalShellIntegration } from '../common/extHostTerminalShell
export class ExtHostDebugService extends ExtHostDebugServiceBase {
override readonly _serviceBrand: undefined;
private _integratedTerminalInstances = new DebugTerminalCollection();
private _terminalDisposedListener: IDisposable | undefined;

View File

@@ -35,7 +35,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
public readonly SIZE_LIMIT = Math.floor(1024 * 1024 * 1.9); // 2 MB
private serverConfiguration = this.productService['editSessions.store'];
private serverConfiguration;
private machineClient: IUserDataSyncMachinesService | undefined;
private authenticationInfo: { sessionId: string; token: string; providerId: string } | undefined;
@@ -84,7 +84,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
@ISecretStorageService private readonly secretStorageService: ISecretStorageService
) {
super();
this.serverConfiguration = this.productService['editSessions.store'];
// If the user signs out of the current session, reset our cached auth state in memory and on disk
this._register(this.authenticationService.onDidChangeSessions((e) => this.onDidChangeSessions(e.event)));

View File

@@ -680,8 +680,8 @@ export class SideBySideDiffElementViewModel extends DiffElementCellViewModelBase
return this.mainDocumentTextModel;
}
override readonly original!: DiffNestedCellViewModel;
override readonly modified!: DiffNestedCellViewModel;
declare readonly original: DiffNestedCellViewModel;
declare readonly modified: DiffNestedCellViewModel;
override readonly type: 'unchanged' | 'modified';
/**

View File

@@ -78,7 +78,7 @@ function validateWebviewBoundary(element: HTMLElement) {
}
export class NotebookCellList extends WorkbenchList<CellViewModel> implements IDisposable, IStyleController, INotebookCellList {
protected override readonly view!: NotebookCellListView<CellViewModel>;
declare readonly view: NotebookCellListView<CellViewModel>;
private viewZones!: NotebookViewZones;
private cellOverlays!: NotebookCellOverlays;
get onWillScroll(): Event<ScrollEvent> { return this.view.onWillScroll; }

View File

@@ -45,10 +45,12 @@ const enum RequestCompletionsSequence {
}
export class PwshCompletionProviderAddon extends Disposable implements ITerminalAddon, ITerminalCompletionProvider {
static readonly ID = 'pwsh-shell-integration';
id: string = PwshCompletionProviderAddon.ID;
triggerCharacters?: string[] | undefined;
isBuiltin?: boolean = true;
static readonly ID = 'pwsh-shell-integration';
readonly shellTypes = [GeneralShellType.PowerShell];
private _lastUserDataTimestamp: number = 0;
private _terminal?: Terminal;