-
Notifications
You must be signed in to change notification settings - Fork 0
TypeScript
alex [dot] kramer [at] g_m_a_i_l [dot] com edited this page Jul 20, 2023
·
7 revisions
See https://localhost.adobe.com:31338/templates/bfebc6a4-6d25-42ba-a52a-3eb070c98c5f
Possible solutions:
- Try running
npm i @types/my-untyped-module
to see if someone has added type declarations to DefinitelyTyped - Create (or add to) a
declarations.d.ts
file with the linedeclare module "my-untyped-module"
and make sure the file is in one of the directories intsconfig.json
's"include": [...]
.
Useful for avoiding manually writing out types for complicated JSON/objects. See also: https://stackoverflow.com/a/42549370
type TYPE_HELPER = ReturnType<typeof someFunction>;
interface Foo {
twoArgs: (x: number, y: number) => void;
}
const giveMeFoo = (): Foo => {
return {
// Only one arg lol
twoArgs: (x: number) => {
console.log(`There is no "y" (R.I.P Kurt)`);
}
};
}
// Requires two args wtf?
giveMeFoo().twoArgs(7, 8);