TypeScript: How to import functions correcly?
See original GitHub issueI’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:
- Created 3 years ago
- Reactions:3
- Comments:9 (6 by maintainers)
Top 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 >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
@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.
@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!