Complete the code to install type definitions for a package using npm.
npm install --save-dev [1]To add type definitions for a package like lodash, you install the corresponding @types package.
Complete the code to import a type from an installed '@types' package.
import type { [1] } from 'lodash';
The type Map is a valid type exported by lodash's type definitions.
Fix the error in the code by completing the import statement for a type from '@types/node'.
import type { [1] } from 'node';
The correct type to import from '@types/node' is Buffer with uppercase B.
Fill both blanks to create a type alias for a function type using types from '@types/lodash'.
type Func = (input: string) => [1]; const example: Func = (input) => [2];
The function returns a number, so the type is number and the example returns the length of the input string.
Fill all three blanks to create a typed object using types from '@types/node' and '@types/lodash'.
import type { [1] } from 'node'; import type { [2] } from 'lodash'; const data: { buf: [1]; fn: [2] } = { buf: Buffer.from('hello'), fn: (arr) => arr.map(x => x * 2) };
The type Buffer is imported from 'node' and Map is a type from 'lodash'. The object uses these types for its properties.