Skip to content

Commit

Permalink
Merge pull request #99 from SwabianCoder/docs/95-add-jsdoc-to-ngx-too…
Browse files Browse the repository at this point in the history
…lset-template-type-checker

📝 Added JSDoc comments to template-type-checker project
  • Loading branch information
SwabianCoder committed Aug 18, 2022
2 parents aa6e762 + 10b514c commit 2c09bdb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
6 changes: 6 additions & 0 deletions projects/template-type-checker/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0-rc.6] - 2022-08-18

### Added

- JSDoc comments

## [1.0.0-rc.5] - 2022-08-15

### Changed
Expand Down
2 changes: 1 addition & 1 deletion projects/template-type-checker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ngx-toolset/template-type-checker",
"version": "1.0.0-rc.5",
"version": "1.0.0-rc.6",
"description": "Validate object's class instance type in Angular HTML template",
"homepage": "https://github.com/SwabianCoder/ngx-toolset",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { NgModule } from '@angular/core';
import { TypeCheckerPipe } from './type-checker.pipe';

/**
* The TemplateTypeCheckerModule containing the {@link https://github.com/SwabianCoder/ngx-toolset/blob/main/projects/template-type-checker/src/lib/type-checker.pipe.ts TypeCheckerPipe}
*
* @export
* @class TemplateTypeCheckerModule
* @typedef {TemplateTypeCheckerModule}
*/
@NgModule({
declarations: [TypeCheckerPipe],
exports: [TypeCheckerPipe],
Expand Down
17 changes: 17 additions & 0 deletions projects/template-type-checker/src/lib/type-checker.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import { Pipe, PipeTransform } from '@angular/core';
import { Constructor } from './types';

/**
* The TypeCheckerPipe validates if an object is an instance of the provided {@link https://github.com/SwabianCoder/ngx-toolset/blob/main/projects/template-type-checker/src/lib/types/constructor.ts className}.
*
* @export
* @class TypeCheckerPipe
* @typedef {TypeCheckerPipe}
* @implements {PipeTransform}
*/
@Pipe({
name: 'typeChecker',
})
export class TypeCheckerPipe implements PipeTransform {
/**
* Validates if an object is an instance of the provided {@link https://github.com/SwabianCoder/ngx-toolset/blob/main/projects/template-type-checker/src/lib/types/constructor.ts className}.
*
* @public
* @template T
* @param {*} obj
* @param {Constructor<T>} className
* @returns {(T | undefined)}
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public transform<T>(obj: any, className: Constructor<T>): T | undefined {
return obj instanceof className ? obj : undefined;
Expand Down
7 changes: 7 additions & 0 deletions projects/template-type-checker/src/lib/types/constructor.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
/**
* Represents the class to validate the object against using {@link https://github.com/SwabianCoder/ngx-toolset/blob/main/projects/template-type-checker/src/lib/type-checker.pipe.ts TypeCheckerPipe}
*
* @export
* @typedef {Constructor}
* @template T
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Constructor<T> = { new (...args: any[]): T };

0 comments on commit 2c09bdb

Please sign in to comment.