Let's suppose I have this:
import type { Collection } from './x.types.js';
import type { Collection } from './y.types.js';
I would like to import both like this:
import type * as XTypes from './x.types.js';
import type * as YTypes from './y.types.js';
because in my code I will have a namespace, I can easily recognise where they are coming from and I will not have any declaration's conflict.
const something = (collection: Xtypes.collection) => {}
const something2 = (collection: Ytypes.collection) => {}
You can import everything from the module and access the types like you would any exports from the module:
(Try)
import * as React from 'react'
const a: React.Element<'div'> = <div>Test</div>
I don't think an import type * as ReactTypes
syntax exists at the moment. If you use the above syntax, I hope you're using tree shaking or you're already using that module somewhere else. It would be a shame to bloat your deployed code just to use this shorthand import.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With