I have a declaration file in my TypeScript project like so:
// myapp.d.ts
declare namespace MyApp {
interface MyThing {
prop1: string
prop2: number
}
}
This works great and I can use this namespace anywhere in my project without having to import it.
I now need to import a type from a 3rd party module and use it in my ambient declaration:
// myapp.d.ts
import {SomeType} from 'module'
declare namespace MyApp {
interface MyThing {
prop1: string
prop2: number
prop3: SomeType
}
}
The compiler now complains that it can't find namespace 'MyApp', presumably because the import prevents it from being ambient.
Is there some easy way to retain the ambient-ness of the declaration whilst utilising 3rd-party types?
luxon
, it comes with typings and looks just like this sample code here -import { DateTime } from 'luxon'
. – Roman Starkov