Skip to content

Commit

Permalink
types: worker types
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 1, 2021
1 parent b782af4 commit 7cc4bb7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/vite/types/fileTypes.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference lib="dom" />

// CSS modules
type CSSModuleClasses = { readonly [key: string]: string }

Expand Down Expand Up @@ -136,3 +138,18 @@ declare module '*.otf' {
const src: string
export default src
}

// web worker
declare module '*?worker' {
const workerConstructor: {
new (): Worker
}
export default workerConstructor
}

declare module '*?worker&inline' {
const workerConstructor: {
new (): Worker
}
export default workerConstructor
}

2 comments on commit 7cc4bb7

@aleclarson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this leaks dom types into NodeJS projects that import vite. We should revert this.

Repro: https://github.com/aleclarson/repro/tree/vite-7cc4bb7

git clone https://github.com/aleclarson/repro -b vite-7cc4bb7
cd vite-7cc4bb7
yarn
code .

@aleclarson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a workaround, users can include these declare module types in their project manually.

Please sign in to comment.