I'm contemplating enhancing an existing project by incorporating TypeScript type annotations. Struggling to supply an external declaration file for a straightforward example:
app.ts:
/// <reference path="types.d.ts"/>
function welcome (person) {
console.log(person.name);
}
var y = {name: 'John'};
welcome(y);
types.d.ts:
interface Person {
height?: number,
name: string
}
declare function greet (person: Person): void;
Although I anticipated success, an error has surfaced:
program.ts(3,10): error TS2384: Overload signatures must all be ambient or non-ambient.
The issue seems to stem from the misunderstanding of the function definition as an overload rather than the implementation of a previous declaration.
How can I correctly add a type to the welcome
function?
Requirement: The app.ts
should remain pure JavaScript, devoid of any type annotations.