What is @types/ejs?
The @types/ejs package provides TypeScript type definitions for EJS (Embedded JavaScript templates). This allows TypeScript developers to use EJS in their projects with the benefits of type checking and IntelliSense support in IDEs. The package does not contain functionality by itself but supports the EJS templating engine by providing types for better development experience in TypeScript environments.
Type Definitions for EJS Functions
Provides type definitions for the `render` function of EJS, enabling type checking and auto-completion features in TypeScript projects.
import * as ejs from 'ejs';
let html: string = ejs.render('Hello <%= user %>!', { user: 'Alice' });
Type Definitions for EJS Configuration Options
Includes type definitions for configuration options in EJS, such as `cache` and `async`, ensuring that developers use the correct types and values when configuring EJS options.
import * as ejs from 'ejs';
ejs.renderFile('template.ejs', { user: 'Bob' }, { cache: true, async: false }, function(err, str) {
// str: rendered HTML string
});