Skip to content

Typescript doesnt allow creating module definitions for certain types of ES6 imports #6656

@pdeva

Description

@pdeva

There is a library I use, 'react-bootstrap-switch', that needs to be imported the following way in TypeScript:

import * as Switch from 'react-bootstrap-switch';

render () {
 return <Switch/>
}

It seems currently TypeScript doesnt allow creating a module definition for a library that exports like this.

If I do this:

declare module 'react-bootstrap-switch'
{
    import React = require("react");
    class Switch extends React.Component<{onColor?:string},{} >
    {}

    export  = Switch;
}

It results in this error:

error TS2497: Module ''react-bootstrap-switch'' resolves to a non-module entity and cannot be imported using this construct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions