Skip to content

Unable to define env/scope of *only* service-worker file in JS project #30750

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

Closed
wilsonpage opened this issue Apr 4, 2019 · 2 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@wilsonpage
Copy link

wilsonpage commented Apr 4, 2019

I'm working on a JS (not TS) project and using VSCode/Typecripts checkjs feature to check/lint the project.

I'm unable to find a way of defining the scope of just the service-worker file to ServiceWorkerGlobalScope without changing the scope of the other files from Window.

I've tried various combinations of sibling .d.ts files and /// <reference lib="…" /> but many of them seem to operate on the project in a 'global' manner, changing the default-lib/scope of all .js files causing loads of errors.


TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms:

"How to define env/scope of service-worker file in VSCode"

Code

https://github.com/wilsonpage/vscode-scope-test-case

Expected behavior:

Should be able to define lib/env of a single file without impacting entire project.

Actual behavior:

When adding /// <reference types="node_modules/types-serviceworker" /> it appears to change the default-lib of all other .js files in the project.

Playground Link:

This is a checkjs issue, not related to typescript project.

Related Issues:

#14877

Related Repo:

https://github.com/shqld/types-serviceworker

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Apr 16, 2019
@RyanCavanaugh
Copy link
Member

You'd need to have different config files or similar. Settings such as lib are per-project, not per file

@wilsonpage
Copy link
Author

wilsonpage commented Apr 24, 2019

@RyanCavanaugh I now have 2 different jsconfig.json files in the reduced test-case.

Two issues:

  1. Service worker file still thinks it's a worker, meaning it's erroring on use of ServiceWorker specific APIs (eg. self.skipWaiting()).
  2. How can I run Typescript's checkjs on the entire project in one go?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants