I have the following files:
AutosuggestComponent.tsx:
import * as React from 'react';
interface AutosuggestProps {
...
}
interface AutosuggestState {
...
}
export default class Autosuggest extends React.Component<AutosuggestProps, AutosuggestState> {
...
}
And I would like to import the Autosuggest component like this in ConsumerComponent.tsx:
import Autosuggest = Components.AutoSuggest;
How can I export AutosuggestComponent.tsx in order to make this work?
I have tried creating an Autosuggest.ts like this:
import AutosuggestComponent from './AutosuggestComponent';
namespace Components {
export const Autosuggest = AutosuggestComponent;
}
which doesn't work. The ConsumerComponent then cannot find the namespace 'Components'. However, this works:
// import AutosuggestComponent from './AutosuggestComponent';
namespace Components {
export const Autosuggest = { dummyValue: "test" }
}
As soon as I comment out the import, the ConsumerComponent is able to find the namespace. Why?
Is there any way to work this out?