Skip to content

Commit aa2673d

Browse files
authored
chore(docs): add invisible unicode char to decorator docs (#1755)
1 parent fbcee9d commit aa2673d

File tree

4 files changed

+50
-57
lines changed

4 files changed

+50
-57
lines changed

packages/idempotency/src/idempotencyDecorator.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import { makeIdempotent } from './makeIdempotent';
1414
* } from '@aws-lambda-powertools/idempotency';
1515
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
1616
*
17-
* class MyLambdaFunction implements LambdaInterface{
18-
* @idempotent({ persistenceStore: new DynamoDBPersistenceLayer() })
19-
* async handler(event: any, context: any) {
17+
* class MyLambdaFunction implements LambdaInterface {
18+
* @idempotent({ persistenceStore: new DynamoDBPersistenceLayer() })
19+
* async handler(event: unknown, _context: unknown) {
2020
* return "Hello World";
2121
* }
2222
* }
@@ -28,23 +28,23 @@ import { makeIdempotent } from './makeIdempotent';
2828
* @example
2929
* ```ts
3030
* import {
31-
* DynamoDBPersistenceLayer,
32-
* idempotentFunction
33-
* } from '@aws-lambda-powertools/idempotency';
34-
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
35-
*
36-
* class MyClass implements LambdaInterface {
31+
* DynamoDBPersistenceLayer,
32+
* idempotentFunction
33+
* } from '@aws-lambda-powertools/idempotency';
34+
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
3735
*
38-
* public async handler(_event: any, _context: any) {
39-
* for(const record of _event.records){
40-
* await this.process(record);
41-
* }
42-
* }
36+
* class MyClass implements LambdaInterface {
37+
* public async handler(event: unknown, _context: unknown) {
38+
* for(const record of event.records){
39+
* await this.process(record);
40+
* }
41+
* }
4342
*
44-
* @idemptent({ persistenceStore: new DynamoDBPersistenceLayer() })
45-
* public async process(record: Record<stiring, unknown) {
43+
* @idemptent({ persistenceStore: new DynamoDBPersistenceLayer() })
44+
* public async process(record: Record<stiring, unknown>) {
4645
* // do some processing
47-
* }
46+
* }
47+
* }
4848
* ```
4949
* @see {@link DynamoDBPersistenceLayer}
5050
* @see https://www.typescriptlang.org/docs/handbook/decorators.html

packages/logger/src/Logger.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import type {
5858
*
5959
* const logger = new Logger();
6060
*
61-
* const lambdaHandler = async (_event: any, _context: any) => {
61+
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
6262
* logger.info('This is an INFO log with some context');
6363
* };
6464
*
@@ -77,12 +77,9 @@ import type {
7777
* const logger = new Logger();
7878
*
7979
* class Lambda implements LambdaInterface {
80-
*
81-
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@logger* instead of `@logger.injectLambdaContext`
82-
*
8380
* // Decorate your handler class method
84-
* @logger.injectLambdaContext()
85-
* public async handler(_event: any, _context: any): Promise<void> {
81+
* @logger.injectLambdaContext()
82+
* public async handler(_event: unknown, _context: unknown): Promise<void> {
8683
* logger.info('This is an INFO log with some context');
8784
* }
8885
* }
@@ -358,8 +355,8 @@ class Logger extends Utility implements ClassThatLogs {
358355
*
359356
* class Lambda implements LambdaInterface {
360357
* // Decorate your handler class method
361-
* @logger.injectLambdaContext()
362-
* public async handler(_event: any, _context: any): Promise<void> {
358+
* @logger.injectLambdaContext()
359+
* public async handler(_event: unknown, _context: unknown): Promise<void> {
363360
* logger.info('This is an INFO log with some context');
364361
* }
365362
* }

packages/metrics/src/Metrics.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {
5454
*
5555
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
5656
*
57-
* const lambdaHandler = async (_event: any, _context: any) => {
57+
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
5858
* ...
5959
* };
6060
*
@@ -77,11 +77,9 @@ import {
7777
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
7878
*
7979
* class Lambda implements LambdaInterface {
80-
*
81-
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@metrics* instead of `@metrics.logMetrics`
82-
*
83-
* @metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
84-
* public handler(_event: any, _context: any): Promise<void> {
80+
* // Decorate your handler with the logMetrics decorator
81+
* ⁣@metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
82+
* public handler(_event: unknown, _context: unknown): Promise<void> {
8583
* // ...
8684
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
8785
* // ...
@@ -103,7 +101,7 @@ import {
103101
*
104102
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
105103
*
106-
* export const handler = async (_event: any, _context: any): Promise<void> => {
104+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
107105
* metrics.captureColdStartMetric();
108106
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
109107
* metrics.publishStoredMetrics();
@@ -243,7 +241,7 @@ class Metrics extends Utility implements MetricsInterface {
243241
*
244242
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
245243
*
246-
* export const handler = async (event: any, _context: any): Promise<void> => {
244+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
247245
* metrics.captureColdStartMetric();
248246
* };
249247
* ```
@@ -305,7 +303,7 @@ class Metrics extends Utility implements MetricsInterface {
305303
* class Lambda implements LambdaInterface {
306304
*
307305
* @metrics.logMetrics({ captureColdStartMetric: true })
308-
* public handler(_event: any, _context: any): Promise<void> {
306+
* public handler(_event: unknown, __context: unknown): Promise<void> {
309307
* // ...
310308
* }
311309
* }
@@ -373,7 +371,7 @@ class Metrics extends Utility implements MetricsInterface {
373371
*
374372
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); // Sets metric namespace, and service as a metric dimension
375373
*
376-
* export const handler = async (_event: any, _context: any): Promise<void> => {
374+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
377375
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
378376
* metrics.publishStoredMetrics();
379377
* };
@@ -523,7 +521,7 @@ class Metrics extends Utility implements MetricsInterface {
523521
*
524522
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName:'orders' });
525523
*
526-
* export const handler = async (_event: any, _context: any): Promise<void> => {
524+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
527525
* metrics.throwOnEmptyMetrics();
528526
* metrics.publishStoredMetrics(); // will throw since no metrics added.
529527
* };

packages/tracer/src/Tracer.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { type Segment, Subsegment } from 'aws-xray-sdk-core';
5151
*
5252
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
5353
*
54-
* const lambdaHandler = async (_event: any, _context: any) => {
54+
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
5555
* ...
5656
* };
5757
*
@@ -73,11 +73,9 @@ import { type Segment, Subsegment } from 'aws-xray-sdk-core';
7373
*
7474
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
7575
*
76-
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@tracer* instead of `@tracer.captureLambdaHandler`
77-
*
7876
* class Lambda implements LambdaInterface {
79-
* @tracer.captureLambdaHandler()
80-
* public handler(event: any, context: any) {
77+
* @tracer.captureLambdaHandler()
78+
* public handler(_event: unknown, _context: unknown) {
8179
* ...
8280
* }
8381
* }
@@ -96,7 +94,7 @@ import { type Segment, Subsegment } from 'aws-xray-sdk-core';
9694
*
9795
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
9896
*
99-
* export const handler = async (_event: any, context: any) => {
97+
* export const handler = async (_event: unknown, _context: unknown) => {
10098
* const segment = tracer.getSegment(); // This is the facade segment (the one that is created by AWS Lambda)
10199
* // Create subsegment for the function & set it as active
102100
* const subsegment = segment.addNewSubsegment(`## ${process.env._HANDLER}`);
@@ -246,7 +244,7 @@ class Tracer extends Utility implements TracerInterface {
246244
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
247245
* const AWS = tracer.captureAWS(require('aws-sdk'));
248246
*
249-
* export const handler = async (_event: any, _context: any) => {
247+
* export const handler = async (_event: unknown, _context: unknown) => {
250248
* ...
251249
* }
252250
* ```
@@ -275,7 +273,7 @@ class Tracer extends Utility implements TracerInterface {
275273
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
276274
* const s3 = tracer.captureAWSClient(new S3({ apiVersion: '2006-03-01' }));
277275
*
278-
* export const handler = async (_event: any, _context: any) => {
276+
* export const handler = async (_event: unknown, _context: unknown) => {
279277
* ...
280278
* }
281279
* ```
@@ -318,7 +316,7 @@ class Tracer extends Utility implements TracerInterface {
318316
* const client = new S3Client({});
319317
* tracer.captureAWSv3Client(client);
320318
*
321-
* export const handler = async (_event: any, _context: any) => {
319+
* export const handler = async (_event: unknown, _context: unknown) => {
322320
* ...
323321
* }
324322
* ```
@@ -352,9 +350,9 @@ class Tracer extends Utility implements TracerInterface {
352350
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
353351
*
354352
* class Lambda implements LambdaInterface {
355-
* @tracer.captureLambdaHandler()
356-
* public handler(event: any, context: any) {
357-
* ...
353+
* @tracer.captureLambdaHandler()
354+
* public handler(_event: unknown, _context: unknown) {
355+
* // ...
358356
* }
359357
* }
360358
*
@@ -445,13 +443,13 @@ class Tracer extends Utility implements TracerInterface {
445443
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
446444
*
447445
* class Lambda implements LambdaInterface {
448-
* @tracer.captureMethod()
449-
* public myMethod(param: any) {
450-
* ...
446+
* @tracer.captureMethod()
447+
* public myMethod(param: string) {
448+
* // ...
451449
* }
452450
*
453-
* public handler(event: any, context: any) {
454-
* ...
451+
* public handler(_event: unknown, _context: unknown) {
452+
* this.myMethod('foo');
455453
* }
456454
* }
457455
*
@@ -567,7 +565,7 @@ class Tracer extends Utility implements TracerInterface {
567565
*
568566
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
569567
*
570-
* export const handler = async (_event: any, _context: any) => {
568+
* export const handler = async (_event: unknown, _context: unknown) => {
571569
* const currentSegment = tracer.getSegment();
572570
* ... // Do something with segment
573571
* }
@@ -627,7 +625,7 @@ class Tracer extends Utility implements TracerInterface {
627625
*
628626
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
629627
*
630-
* export const handler = async (_event: any, _context: any) => {
628+
* export const handler = async (_event: unknown, _context: unknown) => {
631629
* tracer.putAnnotation('successfulBooking', true);
632630
* }
633631
* ```
@@ -652,7 +650,7 @@ class Tracer extends Utility implements TracerInterface {
652650
*
653651
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
654652
*
655-
* export const handler = async (_event: any, _context: any) => {
653+
* export const handler = async (_event: unknown, _context: unknown) => {
656654
* const res = someLogic();
657655
* tracer.putMetadata('paymentResponse', res);
658656
* }
@@ -686,7 +684,7 @@ class Tracer extends Utility implements TracerInterface {
686684
*
687685
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
688686
*
689-
* export const handler = async (_event: any, _context: any) => {
687+
* export const handler = async (_event: unknown, _context: unknown) => {
690688
* const subsegment = new Subsegment('### foo.bar');
691689
* tracer.setSegment(subsegment);
692690
* }

0 commit comments

Comments
 (0)