Skip to content

Commit 8ae0c5c

Browse files
fix: SLS Framework types
1 parent c1f41df commit 8ae0c5c

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/frameworks/slsFramework.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33
import { EsBuildOptions, LambdaResource } from '../types/resourcesDiscovery.js';
44
import { constants } from 'fs';
55
import { findPackageJson } from '../utils/findPackageJson.js';
6-
import type Serverless from 'serverless';
6+
import type { Serverless } from './slsFrameworkTypes.js';
77
import { IFramework } from './iFrameworks.js';
88
import { LldConfigBase } from '../types/lldConfig.js';
99
import { Logger } from '../logger.js';
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Mock types for the Serverless Framework.
3+
* Used when the 'serverless' package is not installed (e.g. optional/peer dependency).
4+
* Mirrors @types/serverless shapes used by this project.
5+
*/
6+
7+
/**
8+
* Service instance shape (matches Service class in @types/serverless).
9+
* This project only supports handler-based functions; functions is typed accordingly so no cast is needed.
10+
*/
11+
export interface ServerlessService {
12+
custom: Record<string, any>;
13+
plugins: string[];
14+
functions?: Record<string, ServerlessFunctionDefinitionHandler>;
15+
}
16+
17+
/**
18+
* Base function definition (matches Serverless.FunctionDefinition in @types/serverless).
19+
*/
20+
export interface ServerlessFunctionDefinitionBase {
21+
name?: string;
22+
package?: Record<string, any>;
23+
reservedConcurrency?: number;
24+
runtime?: string;
25+
timeout?: number;
26+
memorySize?: number;
27+
environment?: Record<string, string>;
28+
events?: unknown[];
29+
tags?: Record<string, string>;
30+
[key: string]: any;
31+
}
32+
33+
/**
34+
* Handler-based function (matches Serverless.FunctionDefinitionHandler).
35+
*/
36+
export interface ServerlessFunctionDefinitionHandler extends ServerlessFunctionDefinitionBase {
37+
handler: string;
38+
}
39+
40+
/**
41+
* Serverless instance (matches Serverless class in @types/serverless).
42+
* The real class is loaded dynamically; this type describes the shape we use.
43+
*/
44+
export interface Serverless {
45+
service: ServerlessService;
46+
init(): Promise<void>;
47+
run(): Promise<void>;
48+
}
49+
50+
/** Namespace for Serverless.FunctionDefinitionHandler (used in slsFramework cast). */
51+
// eslint-disable-next-line @typescript-eslint/no-namespace -- needed for Serverless.FunctionDefinitionHandler with no slsFramework changes
52+
export namespace Serverless {
53+
export type FunctionDefinitionHandler = ServerlessFunctionDefinitionHandler;
54+
}

0 commit comments

Comments
 (0)