"Ambient context" in typescript terms means "anything that does not have an implementation", that does not emit javascript codes. It only exists in the type system at compile time, and is erased at run-time. "declare", "type", "interface" etc., are all ambient context.
A ".d.ts" contains only ambient context. Rule is:
declare const something:string; // okdeclare const somethingElse:string = "with value"; // wrongimport {User} from "./user" // wrongdeclare namespace Express { interface Request { user: import("./user").User; // ok }}To declare type for javascript (which has no type). It tells compiler to trust, at run time, there's a declared something as some type.
What works and not works (to place declaration file and config compiler option)
Works
Not works: