Documentation example doesn't work with TypeScript
See original GitHub issuePrerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn’t contain the answer to my issue
Environment check
- I’m using the latest
msw
version - I’m using Node.js version 14 or higher
Browsers
No response
Reproduction repository
https://stackblitz.com/edit/node-ifch93?file=index.ts
Reproduction steps
Use documentation example with typescript https://mswjs.io/docs/getting-started/integrate/browser#configure-worker
// src/mocks/browser.js
import { setupWorker } from 'msw'
import { handlers } from './handlers'
// This configures a Service Worker with the given request handlers.
export const worker = setupWorker(...handlers)
Current behavior
Typescript throws multiple
TS4094: Property 'SOMETHING' of exported class expression may not be private or protected.
Expected behavior
I expect typescript to be fine with that
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
JSDoc Reference - TypeScript: Documentation
Documentation tags work in both TypeScript and JavaScript. ... @type can specify a union type — for example, something can be either a...
Read more >Working with JavaScript in Visual Studio Code
Working with JavaScript. This topic describes some of the advanced JavaScript features supported by Visual Studio Code. Using the TypeScript language ...
Read more >TypeScript - Cypress Documentation
You may have to restart your IDE's TypeScript server if the setup above does not appear to work. For example: VS Code (within...
Read more >Using TypeScript - Expo Documentation
For example, you would rename App.js to App.tsx. Use the .tsx extension if the file includes React components (JSX). If the file did...
Read more >TypeScript | IntelliJ IDEA Documentation - JetBrains
Verify TypeScript in the entire project · To open the Problems tool window, click the Inspections widget in the upper-right corner of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kettanaito I opened a PR to reuse the existing interface describing the class
SetupWorkerApi
. For me it is the only way to have it working on the consumer side (without the above workaround), but maybe you want to check the interfaceSetupWorkerApi
is describing well enough the classSetupWorkerApi
(at least TS it is matching according to TS)@gduliscouet-ubitransport Adding the type annotation to the
worker
constant instead of using TypeScript inference allows me to output the definition file without errors.