Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous type definitions: Type Worker is not exported #20

Open
LinqLover opened this issue Sep 10, 2021 · 0 comments
Open

Erroneous type definitions: Type Worker is not exported #20

LinqLover opened this issue Sep 10, 2021 · 0 comments

Comments

@LinqLover
Copy link

When compiling a TypeScript project that refers to this package, I get the following error:

node_modules/web-worker/index.d.ts:3:39 - error TS2304: Cannot find name 'Worker'.

3 declare const _default: ConstructorOf<Worker>
                                        ~~~~~~
niedzielski added a commit to niedzielski/web-worker that referenced this issue May 18, 2022
- Add types entry exports[0]. I'm sad TypeScript doesn't seem to be
  using the plain old types field but it isn't.
- Replace index.d.ts' `export default` with `export =`[1]. From what I
  can tell, `module.exports` is always used for all entrypoints so this
  is the correct definition.
- Use the Worker var declaration from lib.dom.d.ts. I think this is fine
  since the old definition already used the Worker interface from the
  same file. This typing is more accurate, easier to read,d less likely
  to become outdated, and less code.

Bug: developit#20 developit#22

[0]: https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#packagejson-exports-imports-and-self-referencing
[1]: microsoft/TypeScript#7185 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant