score:1
Try this:
export { Modal, ModalGateway };
export default Carousel;
score:1
Since I haven't found any solution anywhere, I would like to share my solution. The key is to create an interface with default anonymous method and export a variable instance of this interface.
Example
module.d.ts
interface GeoTz {
/**
* Get TZ ids for lat/lon. It can throw an exception if coordinates are invalid.
*
* @param lat Latitude
* @param lon Longitude
* @returns TZ ids for coordinates, e.g. ['Asia/Shanghai', 'Asia/Urumqi']
* @throws An exception if coordinates are invalid
*/
(lat: string | number, lon: string | number): string[];
/**
* Can change the cache behavior, such as preload everything into memory or use custom get/set store functions
*
* @param opts Custom options for cache
*/
setCache(opts: {
preload?: boolean;
store?: {
get: (key: string) => import('geojson').GeoJSON;
set: (key: string, data: import('geojson').GeoJSON) => void;
};
}): void;
}
declare module 'geo-tz' {
const geoTz: GeoTz;
export = geoTz;
}
Then in code both works:
import geoTz from 'geo-tz';
geoTz.setCache({ preload: true });
geoTz('49.000', '14.000');
Source: stackoverflow.com
Related Query
- declare module in typescript with both default and named exports
- Create React App with TypeScript and NPM Link: Enums causing Module parse failed
- Does importing the default export along with a named export load the module twice?
- How to declare different state and props for subclasses on react with typescript
- React.render in TypeScript for component with both props and state
- React library with typescript and module css
- How create React Typescript component with required and optional values but required value without default value?
- Trying to use jest with create-react-app and typescript. Get error: Jest: Failed to parse the TypeScript config file... Cannot find module 'ts-node'
- Next.js app with both Javascript and Typescript
- How to mock the npm module that exports the default and the object
- Issue with Module Redirecting named exports
- What is the difference between .ts and .tsx extensions. Both are used as extensions for typescript files in react. So where should we use them?
- Specifying onClick event type with Typescript and React.Konva
- How to specify (optional) default props with TypeScript for stateless, functional React components?
- Using styled-components with props and TypeScript
- A module cannot have multiple default exports
- Cannot mock a module with jest, and test function calls
- ES2015 module syntax is preferred over custom TypeScript modules and namespaces @typescript-eslint/no-namespace
- React - useRef with TypeScript and functional component
- Both right and left aligned icons in AppBar with material-ui next
- Typescript and React setting initial state with empty typed array
- React hook useRef not working with styled-components and typescript
- How to use TypeScript with withRouter, connect, React.Component and custom properties?
- You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports
- React event handlers with Typescript and JSX
- How to use React with Typescript and SASS
- Jest: How to mock default export Component when same module also has named export?
- Is there a way to both destructure a function parameter, and keep a named reference to the parameter?
- How should I declare a Stateless Functional Component with Typescript in React?
- StyledComponents with Typescript and ThemeProvider. What are the right types?
More Query from same tag
- How Do I Write A Redux Reducer?
- Need react context to update before redirect
- How to build up a JSX component tree from an array of renderable components?
- Updating object in react under componentDidMount
- testing with images using jest for a next.js project
- Next.js: 'Component' cannot be used as a JSX component
- Next.js server side api call returns 500 internal server error
- How can I get the right response promise?
- how to display the text from text field on the screen by clicking button on React
- ERROR in ./node_modules/axios/lib/adapters/http.js
- Mock Response.headers.get()
- Uncaught (in promise) Error: Invalid hook call. - SPECIAL CASE
- FilePond Plugin Import Error - Could not find a declaration file for '...'
- react using states to toggle sidebar
- ReactJS - react-tree-graph not rendering tree
- React/Typescript - Confused about syntax
- How to create a function for sorting an array of object by some property in reactjs?
- Example of jQuery code next to react code (noob)
- context api - loop in context data
- React MobX - decorators + useObserver don't re-render
- get HTML element style with Javascript
- Rendering Firebase Data in React
- Hide/show state of div react
- How to include Preact component with hooks in React app?
- In a react html5 app, how to a place 3 select lists side by side?
- Trouble Accessing Database. Firebase 9.0
- React redux toolkit 'Cannot set properties of undefined (setting 'check')
- react-stripe-elements not detecting Stripe.js
- Error: Cannot find module 'gatsby-plugin-image/graphql-utils'
- What React hook to use to make it re-render the list each time function is called?