Skip to content

Commit 24c0a18

Browse files
committed
chore(docs): add invisible unicode char to decorator docs (#1755)
1 parent e7eca23 commit 24c0a18

File tree

4 files changed

+50
-57
lines changed

4 files changed

+50
-57
lines changed

Diff for: packages/idempotency/src/idempotencyDecorator.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import { makeIdempotent } from './makeIdempotent.js';
1717
* } from '@aws-lambda-powertools/idempotency';
1818
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
1919
*
20-
* class MyLambdaFunction implements LambdaInterface{
21-
* @idempotent({ persistenceStore: new DynamoDBPersistenceLayer() })
22-
* async handler(event: any, context: any) {
20+
* class MyLambdaFunction implements LambdaInterface {
21+
* @idempotent({ persistenceStore: new DynamoDBPersistenceLayer() })
22+
* async handler(event: unknown, _context: unknown) {
2323
* return "Hello World";
2424
* }
2525
* }
@@ -31,23 +31,23 @@ import { makeIdempotent } from './makeIdempotent.js';
3131
* @example
3232
* ```ts
3333
* import {
34-
* DynamoDBPersistenceLayer,
35-
* idempotentFunction
36-
* } from '@aws-lambda-powertools/idempotency';
37-
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
38-
*
39-
* class MyClass implements LambdaInterface {
34+
* DynamoDBPersistenceLayer,
35+
* idempotentFunction
36+
* } from '@aws-lambda-powertools/idempotency';
37+
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
4038
*
41-
* public async handler(_event: any, _context: any) {
42-
* for(const record of _event.records){
43-
* await this.process(record);
44-
* }
45-
* }
39+
* class MyClass implements LambdaInterface {
40+
* public async handler(event: unknown, _context: unknown) {
41+
* for(const record of event.records){
42+
* await this.process(record);
43+
* }
44+
* }
4645
*
47-
* @idemptent({ persistenceStore: new DynamoDBPersistenceLayer() })
48-
* public async process(record: Record<stiring, unknown) {
46+
* @idemptent({ persistenceStore: new DynamoDBPersistenceLayer() })
47+
* public async process(record: Record<stiring, unknown>) {
4948
* // do some processing
50-
* }
49+
* }
50+
* }
5151
* ```
5252
* @see {@link DynamoDBPersistenceLayer}
5353
* @see https://www.typescriptlang.org/docs/handbook/decorators.html

Diff for: packages/logger/src/Logger.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import type {
6161
*
6262
* const logger = new Logger();
6363
*
64-
* const lambdaHandler = async (_event: any, _context: any) => {
64+
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
6565
* logger.info('This is an INFO log with some context');
6666
* };
6767
*
@@ -80,12 +80,9 @@ import type {
8080
* const logger = new Logger();
8181
*
8282
* class Lambda implements LambdaInterface {
83-
*
84-
* // 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`
85-
*
8683
* // Decorate your handler class method
87-
* @logger.injectLambdaContext()
88-
* public async handler(_event: any, _context: any): Promise<void> {
84+
* @logger.injectLambdaContext()
85+
* public async handler(_event: unknown, _context: unknown): Promise<void> {
8986
* logger.info('This is an INFO log with some context');
9087
* }
9188
* }
@@ -361,8 +358,8 @@ class Logger extends Utility implements ClassThatLogs {
361358
*
362359
* class Lambda implements LambdaInterface {
363360
* // Decorate your handler class method
364-
* @logger.injectLambdaContext()
365-
* public async handler(_event: any, _context: any): Promise<void> {
361+
* @logger.injectLambdaContext()
362+
* public async handler(_event: unknown, _context: unknown): Promise<void> {
366363
* logger.info('This is an INFO log with some context');
367364
* }
368365
* }

Diff for: packages/metrics/src/Metrics.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {
5353
*
5454
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
5555
*
56-
* const lambdaHandler = async (_event: any, _context: any) => {
56+
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
5757
* ...
5858
* };
5959
*
@@ -76,11 +76,9 @@ import {
7676
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
7777
*
7878
* class Lambda implements LambdaInterface {
79-
*
80-
* // 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`
81-
*
82-
* @metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
83-
* public handler(_event: any, _context: any): Promise<void> {
79+
* // Decorate your handler with the logMetrics decorator
80+
* ⁣@metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
81+
* public handler(_event: unknown, _context: unknown): Promise<void> {
8482
* // ...
8583
* metrics.addMetric('test-metric', MetricUnit.Count, 10);
8684
* // ...
@@ -102,7 +100,7 @@ import {
102100
*
103101
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
104102
*
105-
* export const handler = async (_event: any, _context: any): Promise<void> => {
103+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
106104
* metrics.captureColdStartMetric();
107105
* metrics.addMetric('test-metric', MetricUnit.Count, 10);
108106
* metrics.publishStoredMetrics();
@@ -242,7 +240,7 @@ class Metrics extends Utility implements MetricsInterface {
242240
*
243241
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
244242
*
245-
* export const handler = async (event: any, _context: any): Promise<void> => {
243+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
246244
* metrics.captureColdStartMetric();
247245
* };
248246
* ```
@@ -304,7 +302,7 @@ class Metrics extends Utility implements MetricsInterface {
304302
* class Lambda implements LambdaInterface {
305303
*
306304
* @metrics.logMetrics({ captureColdStartMetric: true })
307-
* public handler(_event: any, _context: any): Promise<void> {
305+
* public handler(_event: unknown, __context: unknown): Promise<void> {
308306
* // ...
309307
* }
310308
* }
@@ -372,7 +370,7 @@ class Metrics extends Utility implements MetricsInterface {
372370
*
373371
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); // Sets metric namespace, and service as a metric dimension
374372
*
375-
* export const handler = async (_event: any, _context: any): Promise<void> => {
373+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
376374
* metrics.addMetric('test-metric', MetricUnit.Count, 10);
377375
* metrics.publishStoredMetrics();
378376
* };
@@ -522,7 +520,7 @@ class Metrics extends Utility implements MetricsInterface {
522520
*
523521
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName:'orders' });
524522
*
525-
* export const handler = async (_event: any, _context: any): Promise<void> => {
523+
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
526524
* metrics.throwOnEmptyMetrics();
527525
* metrics.publishStoredMetrics(); // will throw since no metrics added.
528526
* };

Diff for: packages/tracer/src/Tracer.ts

+19-21
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
*
@@ -569,7 +567,7 @@ class Tracer extends Utility implements TracerInterface {
569567
*
570568
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
571569
*
572-
* export const handler = async (_event: any, _context: any) => {
570+
* export const handler = async (_event: unknown, _context: unknown) => {
573571
* const currentSegment = tracer.getSegment();
574572
* ... // Do something with segment
575573
* }
@@ -629,7 +627,7 @@ class Tracer extends Utility implements TracerInterface {
629627
*
630628
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
631629
*
632-
* export const handler = async (_event: any, _context: any) => {
630+
* export const handler = async (_event: unknown, _context: unknown) => {
633631
* tracer.putAnnotation('successfulBooking', true);
634632
* }
635633
* ```
@@ -654,7 +652,7 @@ class Tracer extends Utility implements TracerInterface {
654652
*
655653
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
656654
*
657-
* export const handler = async (_event: any, _context: any) => {
655+
* export const handler = async (_event: unknown, _context: unknown) => {
658656
* const res = someLogic();
659657
* tracer.putMetadata('paymentResponse', res);
660658
* }
@@ -688,7 +686,7 @@ class Tracer extends Utility implements TracerInterface {
688686
*
689687
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
690688
*
691-
* export const handler = async (_event: any, _context: any) => {
689+
* export const handler = async (_event: unknown, _context: unknown) => {
692690
* const subsegment = new Subsegment('### foo.bar');
693691
* tracer.setSegment(subsegment);
694692
* }

0 commit comments

Comments
 (0)