question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript: How to import functions correcly?

See original GitHub issue

I’m trying to mocking REST API and import rest namespace for this:

import { rest } from 'msw'

But when checking the types (built-in in the Vue CLI), an error occurs:

ERROR in [project-path]/node_modules/msw/lib/index.d.ts
3:10 String literal expected.
    1 | export { composeMocks } from './composeMocks';
    2 | export { MockedResponse, ResponseTransformer, response } from './response';
  > 3 | export * as context from './context';
      |          ^
    4 | export * from './handlers/requestHandler';
    5 | export { default as rest, restContext, RESTMethods } from './handlers/rest';
    6 | export { default as graphql, graphqlContext } from './handlers/graphql';

I use TypeScript 3.7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kettanaitocommented, Apr 27, 2020

@tryfonkov, my pleasure! Feel free to reach out in the issues in case you have any other questions regarding the library. I’m always happy to help.

1reaction
tryfonkovcommented, Apr 27, 2020

@kettanaito, sorry for late reply. Yes, TS 3.7 did not support export * as syntax. Therefore, updating to TS 3.8 solved my problem. Explicit exports are supported in TS 3.7 as well. Thank!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing functions in typescript - Stack Overflow
One option is simply to compile your library into a .js output file (and .d.ts typescript definitions ...
Read more >
Import Statements in TypeScript: Which Syntax to Use
TypeScript has multiple syntaxes for imports. When should you use which? It depends. In this blog, Jessica Kerr shares her thoughts, ...
Read more >
Dynamic import() Expressions in TypeScript - Marius Schulz
An import(specifier) expression is a special syntactic form for loading a module. The syntax is reminiscent of a function call that passes a ......
Read more >
Documentation - Modules - TypeScript
Prior to TypeScript 3.8, you can import a type using import . With TypeScript 3.8, you can import a type using the import...
Read more >
How To Use Functions in TypeScript - DigitalOcean
TypeScript fully supports the existing JavaScript syntax for functions, while also adding type information and function overloading as new ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found