Skip to content

Commit

Permalink
WIP - keep only @reflect JSDoc tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Hookyns committed Feb 12, 2022
1 parent 1ffedd6 commit 5040a4c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 47 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog
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] - 2022-01-01)
[//]: # (### Added)
[//]: # (### Changed)

## [0.6.0-beta.5] - 2022-02-20
### Added
### Changed
- JSDoc tags @reflectGeneric and @reflectDecorator removed in favor of single @reflect
9 changes: 2 additions & 7 deletions runtime/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
export const TYPE_ID_PROPERTY_NAME = "__tst_reflect__";

/**
* Name of JSDoc comment marking method as it use type of generic parameter.
* Name of JSDoc comment forcing generic type reflection.
*/
export const REFLECT_GENERIC_DECORATOR = "reflectGeneric";

/**
* Name of JSDoc comment marking function as decorator.
*/
export const REFLECT_DECORATOR_DECORATOR = "reflectDecorator";
export const REFLECT_DECORATOR = "reflect";

/**
* Name of the getType() function
Expand Down
6 changes: 3 additions & 3 deletions transformer/src/getGenericParametersDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
STATE_PROP
} from "./FunctionLikeDeclarationGenericParametersDetail";
import {
hasAnyReflectJsDoc
hasReflectJsDoc
} from "./helpers";
import { isGetTypeCall } from "./isGetTypeCall";

Expand Down Expand Up @@ -40,8 +40,8 @@ export function getGenericParametersDetails(

if (symbol !== undefined)
{
// If declaration contains @reflectGeneric in JSDoc comment, pass all generic arguments
if (hasAnyReflectJsDoc(symbol))
// If declaration contains @reflect in JSDoc comment, pass all generic arguments
if (hasReflectJsDoc(symbol))
{
const genericParams = node.typeParameters.map(p => p.name.escapedText.toString());
const state: FunctionLikeDeclarationGenericParametersDetail = {
Expand Down
41 changes: 4 additions & 37 deletions transformer/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ import * as path from "path";
import {
AccessModifier,
Accessor,
REFLECT_DECORATOR_DECORATOR,
REFLECT_GENERIC_DECORATOR,
REFLECT_DECORATOR,
TypeKind
} from "tst-reflect";
import * as ts from "typescript";
import {
Identifier,
ModifiersArray,
SyntaxKind
} from "typescript";
import { MetadataTypeValues } from "./config-options";
import { Context } from "./contexts/Context";
import TransformerContext from "./contexts/TransformerContext";
import {
Expand Down Expand Up @@ -164,45 +161,15 @@ export function isExpression(value: any)
* Check that function-like declaration has JSDoc with @reflectGeneric tag.
* @param symbol
*/
export function hasReflectGenericJsDoc(symbol: ts.Symbol | undefined): boolean
export function hasReflectJsDoc(symbol: ts.Symbol | undefined): boolean
{
if (!symbol)
{
return false;
}

// If declaration contains @reflectGeneric in JSDoc comment, pass all generic arguments
return symbol.getJsDocTags().some(tag => tag.name === REFLECT_GENERIC_DECORATOR);
}

/**
* Check that function-like declaration has JSDoc with @reflectDecorator tag.
* @param symbol
*/
export function hasReflectDecoratorJsDoc(symbol: ts.Symbol | undefined): boolean
{
if (!symbol)
{
return false;
}

// If declaration contains @reflectDecorator in JSDoc comment, pass all generic arguments
return symbol.getJsDocTags().some(tag => tag.name === REFLECT_DECORATOR_DECORATOR);
}

/**
* Check that function-like declaration has JSDoc with @reflectGeneric tag.
* @param symbol
*/
export function hasAnyReflectJsDoc(symbol: ts.Symbol | undefined): boolean
{
if (!symbol)
{
return false;
}

// If declaration contains any @reflectXxx in JSDoc comment, pass all generic arguments
return symbol.getJsDocTags().some(tag => tag.name === REFLECT_GENERIC_DECORATOR || tag.name === REFLECT_DECORATOR_DECORATOR);
// If declaration contains @reflect in JSDoc comment, pass all generic arguments
return symbol.getJsDocTags().some(tag => tag.name === REFLECT_DECORATOR);
}

/**
Expand Down

0 comments on commit 5040a4c

Please sign in to comment.