Skip to content

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

@wilsonpage

Description

@wilsonpage

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions