Skip to content

Commit 37bdfc1

Browse files
fix(types): add a global interface for Worker (vitejs#20243)
Co-authored-by: sapphi-red <[email protected]>
1 parent 6f51997 commit 37bdfc1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/vite/tsconfig.check.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"target": "ES2020",
44
"moduleResolution": "node16",
55
"module": "Node16",
6-
"lib": ["ES2020", "WebWorker"], // ES2020 is very conservative check for client types, could be bumped if needed
6+
"lib": ["ES2020"], // ES2020 is very conservative check for client types, could be bumped if needed
77
"types": [], // Avoid checking unrelated node_modules types
88
"noEmit": true,
99
"strict": true,

packages/vite/types/importGlob.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ export interface ImportGlobOptions<
3636

3737
export type GeneralImportGlobOptions = ImportGlobOptions<boolean, string>
3838

39+
/**
40+
* Declare Worker in case DOM is not added to the tsconfig lib causing
41+
* Worker interface is not defined. For developers with DOM lib added,
42+
* the Worker interface will be merged correctly.
43+
*/
44+
declare global {
45+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
46+
interface Worker {}
47+
}
48+
3949
export interface KnownAsTypeMap {
4050
raw: string
4151
url: string

0 commit comments

Comments
 (0)