Skip to content

Commit 5535b45

Browse files
authored
debt - more powerful layer checker with TS support (microsoft#250752)
1 parent 7774f73 commit 5535b45

File tree

11 files changed

+94
-11
lines changed

11 files changed

+94
-11
lines changed

build/lib/layersChecker.js renamed to build/checker/layersChecker.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/layersChecker.ts renamed to build/checker/layersChecker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function checkFile(program: ts.Program, sourceFile: ts.SourceFile, rule: IRule)
318318

319319
if (rule.disallowedTypes?.some(disallowed => disallowed === text)) {
320320
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
321-
console.log(`[build/lib/layersChecker.ts]: Reference to type '${text}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1}). Learn more about our source code organization at https://github.com/microsoft/vscode/wiki/Source-Code-Organization.`);
321+
console.log(`[build/checker/layersChecker.ts]: Reference to type '${text}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1}). Learn more about our source code organization at https://github.com/microsoft/vscode/wiki/Source-Code-Organization.`);
322322

323323
hasErrors = true;
324324
return;
@@ -345,7 +345,7 @@ function checkFile(program: ts.Program, sourceFile: ts.SourceFile, rule: IRule)
345345
if (definitionFileName.indexOf(disallowedDefinition) >= 0) {
346346
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
347347

348-
console.log(`[build/lib/layersChecker.ts]: Reference to symbol '${text}' from '${disallowedDefinition}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1}) Learn more about our source code organization at https://github.com/microsoft/vscode/wiki/Source-Code-Organization.`);
348+
console.log(`[build/checker/layersChecker.ts]: Reference to symbol '${text}' from '${disallowedDefinition}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1}) Learn more about our source code organization at https://github.com/microsoft/vscode/wiki/Source-Code-Organization.`);
349349

350350
hasErrors = true;
351351
return;

build/checker/tsconfig.desktop.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": "./tsconfig.web.json",
3+
"include": [
4+
"../../src/**/common/**/*.ts",
5+
"../../src/**/browser/**/*.ts",
6+
"../../src/**/electron-sandbox/**/*.ts",
7+
"../../src/typings/*.d.ts",
8+
"../../src/vs/monaco.d.ts",
9+
"../../src/vscode-dts/vscode.proposed.*.d.ts",
10+
"../../src/vscode-dts/vscode.d.ts",
11+
"../../node_modules/@webgpu/types/dist/index.d.ts",
12+
"../../node_modules/@types/trusted-types/index.d.ts",
13+
"../../node_modules/@types/wicg-file-system-access/index.d.ts"
14+
],
15+
"exclude": [
16+
"../../src/**/test/**",
17+
"../../src/**/fixtures/**",
18+
"../../src/vs/base/parts/sandbox/electron-sandbox/preload.ts", // Preload scripts for Electron sandbox
19+
"../../src/vs/base/parts/sandbox/electron-sandbox/preload-aux.ts" // have limited access to node.js APIs
20+
]
21+
}

build/checker/tsconfig.server.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"extends": "../../src/tsconfig.base.json",
3+
"compilerOptions": {
4+
"lib": [
5+
"ES2022"
6+
],
7+
"types": [
8+
"node"
9+
],
10+
"noEmit": true,
11+
"skipLibCheck": true
12+
},
13+
"include": [
14+
"../../src/**/common/**/*.ts",
15+
"../../src/**/node/**/*.ts",
16+
"../../src/typings/*.d.ts",
17+
"../../src/vs/monaco.d.ts",
18+
"../../src/vscode-dts/vscode.proposed.*.d.ts",
19+
"../../src/vscode-dts/vscode.d.ts",
20+
"../../node_modules/@types/trusted-types/index.d.ts",
21+
],
22+
"exclude": [
23+
"../../src/**/test/**",
24+
"../../src/**/fixtures/**"
25+
]
26+
}

build/checker/tsconfig.web.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"extends": "../../src/tsconfig.base.json",
3+
"compilerOptions": {
4+
"lib": [
5+
"ES2022",
6+
"DOM",
7+
"DOM.Iterable"
8+
],
9+
"types": [],
10+
"noEmit": true,
11+
"skipLibCheck": true
12+
},
13+
"include": [
14+
"../../src/**/common/**/*.ts",
15+
"../../src/**/browser/**/*.ts",
16+
"../../src/typings/*.d.ts",
17+
"../../src/vs/monaco.d.ts",
18+
"../../src/vscode-dts/vscode.proposed.*.d.ts",
19+
"../../src/vscode-dts/vscode.d.ts",
20+
"../../node_modules/@webgpu/types/dist/index.d.ts",
21+
"../../node_modules/@types/trusted-types/index.d.ts",
22+
"../../node_modules/@types/wicg-file-system-access/index.d.ts"
23+
],
24+
"exclude": [
25+
"../../src/**/test/**",
26+
"../../src/**/fixtures/**"
27+
]
28+
}

build/filters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ module.exports.indentationFilter = [
103103
'!extensions/vscode-api-tests/testWorkspace2/**',
104104
'!build/monaco/**',
105105
'!build/win32/**',
106+
'!build/checker/**',
106107

107108
// except multiple specific files
108109
'!**/package.json',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"monaco-compile-check": "tsc -p src/tsconfig.monaco.json --noEmit",
4545
"tsec-compile-check": "node node_modules/tsec/bin/tsec -p src/tsconfig.tsec.json",
4646
"vscode-dts-compile-check": "tsc -p src/tsconfig.vscode-dts.json && tsc -p src/tsconfig.vscode-proposed-dts.json",
47-
"valid-layers-check": "node build/lib/layersChecker.js",
47+
"valid-layers-check": "node build/checker/layersChecker.js && tsc -p build/checker/tsconfig.web.json && tsc -p build/checker/tsconfig.desktop.json && tsc -p build/checker/tsconfig.server.json",
4848
"define-class-fields-check": "node build/lib/propertyInitOrderChecker.js && tsc -p src/tsconfig.defineClassFields.json",
4949
"update-distro": "node build/npm/update-distro.mjs",
5050
"web": "echo 'npm run web' is replaced by './scripts/code-server' or './scripts/code-web'",

src/typings/base-common.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare global {
1717
function requestIdleCallback(callback: (args: IdleDeadline) => void, options?: { timeout: number }): number;
1818
function cancelIdleCallback(handle: number): void;
1919

20+
2021
// --- timeout / interval (available in all contexts, but different signatures in node.js vs web)
2122

2223
interface TimeoutHandle {readonly _: never; /* this is a trick that seems needed to prevent direct number assignment */}
@@ -26,6 +27,14 @@ declare global {
2627

2728
function setInterval(callback: (...args: any[]) => void, delay?: number, ...args: any[]): Timeout;
2829
function clearInterval(timeout: Timeout | undefined): void;
30+
31+
32+
// --- error
33+
34+
interface ErrorConstructor {
35+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
36+
stackTraceLimit: number;
37+
}
2938
}
3039

3140
export { }

src/vs/platform/files/browser/webFileSystemAccess.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export namespace WebFileSystemAccess {
3636
}
3737
}
3838

39-
// TODO@bpasero adopt official types of FileSystemObserver
4039
export namespace WebFileSystemObserver {
4140

4241
export function supported(obj: any & Window): boolean {

src/vs/workbench/api/common/extHostExtensionService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,7 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
593593
try {
594594
activationTimesBuilder.activateCallStart();
595595
logService.trace(`ExtensionService#_callActivateOptional ${extensionId.value}`);
596-
const scope = typeof global === 'object' ? global : self; // `global` is nodejs while `self` is for workers
597-
const activateResult: Promise<IExtensionAPI> = extensionModule.activate.apply(scope, [context]);
596+
const activateResult: Promise<IExtensionAPI> = extensionModule.activate.apply(globalThis, [context]);
598597
activationTimesBuilder.activateCallStop();
599598

600599
activationTimesBuilder.activateResolveStart();

0 commit comments

Comments
 (0)