Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/converter/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export {EnumConverter} from './enum';
export {IntrinsicConverter} from './intrinsic'
export {StringLiteralConverter} from './string-literal';
export {ReferenceConverter} from './reference';
export {ThisConverter} from './this';
export {TupleConverter} from './tuple';
export {TypeParameterConverter} from './type-parameter';
export {UnionConverter} from './union';
Expand Down
34 changes: 34 additions & 0 deletions src/lib/converter/types/this.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as ts from 'typescript';

import { Type, IntrinsicType } from '../../models/types/index';
import { Component, ConverterTypeComponent, TypeNodeConverter } from '../components';
import { Context } from '../context';

@Component({ name: 'type:this' })
export class ThisConverter extends ConverterTypeComponent implements TypeNodeConverter<ts.Type, ts.ThisTypeNode> {
/**
* Test whether this converter can handle the given TypeScript node.
*/
public supportsNode(context: Context, node: ts.ThisTypeNode, type: ts.Type): boolean {
return node.kind === ts.SyntaxKind.ThisType;
}

/**
* Convert the type reference node to its type reflection.
*
* This is a node based converter, see [[convertTypeReferenceType]] for the type equivalent.
*
* ```
* class SomeClass { }
* var someValue:SomeClass;
* ```
*
* @param context The context object describing the current state the converter is in.
* @param node The type reference node that should be converted.
* @param type The type of the type reference node.
* @returns The type reflection representing the given reference node.
*/
public convertNode(context: Context, node: ts.ThisTypeNode, type: ts.Type): Type {
return new IntrinsicType('this');
}
}
109 changes: 109 additions & 0 deletions src/test/converter/this/specs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"id": 0,
"name": "typedoc",
"kind": 0,
"flags": {},
"children": [
{
"id": 1,
"name": "\"this\"",
"kind": 1,
"kindString": "External module",
"flags": {
"isExported": true
},
"originalName": "%BASE%/this/this.ts",
"children": [
{
"id": 2,
"name": "ChainClass",
"kind": 128,
"kindString": "Class",
"flags": {
"isExported": true
},
"comment": {
"shortText": "ChainClass comment short text.",
"text": "ChainClass comment text.\n"
},
"children": [
{
"id": 3,
"name": "chain",
"kind": 2048,
"kindString": "Method",
"flags": {
"isExported": true,
"isPublic": true
},
"signatures": [
{
"id": 4,
"name": "chain",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"comment": {
"shortText": "Chain method that returns this."
},
"type": {
"type": "instrinct",
"name": "this"
}
}
],
"sources": [
{
"fileName": "this.ts",
"line": 11,
"character": 13
}
]
}
],
"groups": [
{
"title": "Methods",
"kind": 2048,
"children": [
3
]
}
],
"sources": [
{
"fileName": "this.ts",
"line": 6,
"character": 23
}
]
}
],
"groups": [
{
"title": "Classes",
"kind": 128,
"children": [
2
]
}
],
"sources": [
{
"fileName": "this.ts",
"line": 1,
"character": 0
}
]
}
],
"groups": [
{
"title": "External modules",
"kind": 1,
"children": [
1
]
}
]
}
15 changes: 15 additions & 0 deletions src/test/converter/this/this.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* ChainClass comment short text.
*
* ChainClass comment text.
*/
export class ChainClass
{
/**
* Chain method that returns this.
*/
public chain(): this
{
return this;
}
}