When using TypeScript, I had the impression that 'declare' indicates to the compiler that the item is defined elsewhere. How do these two seemingly similar "types" actually differ? Could it be that if the item is not found elsewhere, it defaults to the current one?
EXAMPLE:
SomeTypes.ts
export type FooBarType = 'Foo' | 'Bar';
export declare type FooBarDeclareType = 'Foo' | 'Bar';
Both trigger the expected IDE warnings:
Type "This is not foo or Bar" is not assignable to type 'FooBarType'
import SomeTypes.ts
const getFooOrBarType_expectedWarnings = (): FooBarType => 'This is not foo or Bar';
const getFooOrBarDeclareType_expectedWarnings = (): FooBarDeclareType => 'This is not foo or Bar';
Both 'foo' and 'bar' are correctly declared
const getFooOrBarType_bar = (): FooBarType => 'Bar';
const getFooOrBarDeclareType_bar = (): FooBarDeclareType => 'Bar';
const getFooOrBarType_foo = (): FooBarType => 'Foo';
const getFooOrBarDeclareType_foo = (): FooBarDeclareType => 'Foo';