typescript-parser
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -15,4 +15,4 @@ "use strict"; | ||
`${property.visibility !== undefined ? DeclarationVisibility_1.getVisibilityText(property.visibility) + ' ' : ''}` + | ||
`${property.name}${property.type ? `: ${property.type}` : ''};\n`; | ||
`${property.name}${property.isOptional ? '?' : ''}${property.type ? `: ${property.type}` : ''};\n`; | ||
} | ||
exports.generatePropertyDeclaration = generatePropertyDeclaration; |
@@ -1,2 +0,2 @@ | ||
import { AbstractDeclaration, ScopedDeclaration, TypedDeclaration } from './Declaration'; | ||
import { AbstractDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration'; | ||
import { DeclarationVisibility } from './DeclarationVisibility'; | ||
@@ -13,3 +13,3 @@ /** | ||
*/ | ||
export declare abstract class AccessorDeclaration implements ScopedDeclaration, TypedDeclaration, AbstractDeclaration { | ||
export declare abstract class AccessorDeclaration implements ScopedDeclaration, StaticDeclaration, TypedDeclaration, AbstractDeclaration { | ||
name: string; | ||
@@ -19,5 +19,6 @@ visibility: DeclarationVisibility | undefined; | ||
isAbstract: boolean; | ||
isStatic: boolean; | ||
start?: number | undefined; | ||
end?: number | undefined; | ||
constructor(name: string, visibility: DeclarationVisibility | undefined, type: string | undefined, isAbstract: boolean, start?: number | undefined, end?: number | undefined); | ||
constructor(name: string, visibility: DeclarationVisibility | undefined, type: string | undefined, isAbstract: boolean, isStatic: boolean, start?: number | undefined, end?: number | undefined); | ||
} | ||
@@ -24,0 +25,0 @@ /** |
@@ -14,3 +14,3 @@ "use strict"; | ||
class AccessorDeclaration { | ||
constructor(name, visibility, type, isAbstract, start, end) { | ||
constructor(name, visibility, type, isAbstract, isStatic, start, end) { | ||
this.name = name; | ||
@@ -20,2 +20,3 @@ this.visibility = visibility; | ||
this.isAbstract = isAbstract; | ||
this.isStatic = isStatic; | ||
this.start = start; | ||
@@ -22,0 +23,0 @@ this.end = end; |
@@ -167,1 +167,49 @@ import { Node } from '../Node'; | ||
} | ||
/** | ||
* Interface for possible optional declarations. Contains information if the element is optional or not. | ||
* | ||
* @export | ||
* @interface OptionalDeclaration | ||
* @extends {Declaration} | ||
*/ | ||
export interface OptionalDeclaration extends Declaration { | ||
/** | ||
* Defines if the declaration is optional or not. | ||
* | ||
* @type {boolean} | ||
* @memberof OptionalDeclaration | ||
*/ | ||
isOptional: boolean; | ||
} | ||
/** | ||
* Interface for possible static declarations. | ||
* | ||
* @export | ||
* @interface StaticDeclaration | ||
* @extends {Declaration} | ||
*/ | ||
export interface StaticDeclaration extends Declaration { | ||
/** | ||
* Defines if the declaration is static or not. | ||
* | ||
* @type {boolean} | ||
* @memberof StaticDeclaration | ||
*/ | ||
isStatic: boolean; | ||
} | ||
/** | ||
* Interface for possible async declarations. | ||
* | ||
* @export | ||
* @interface AsyncDeclaration | ||
* @extends {Declaration} | ||
*/ | ||
export interface AsyncDeclaration extends Declaration { | ||
/** | ||
* Defines if the declaration is async or not. | ||
* | ||
* @type {boolean} | ||
* @memberof AsyncDeclaration | ||
*/ | ||
isAsync: boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { CallableDeclaration, ExportableDeclaration } from './Declaration'; | ||
import { AsyncDeclaration, CallableDeclaration, ExportableDeclaration } from './Declaration'; | ||
import { ParameterDeclaration } from './ParameterDeclaration'; | ||
@@ -13,5 +13,6 @@ import { VariableDeclaration } from './VariableDeclaration'; | ||
*/ | ||
export declare class FunctionDeclaration implements CallableDeclaration, ExportableDeclaration { | ||
export declare class FunctionDeclaration implements AsyncDeclaration, CallableDeclaration, ExportableDeclaration { | ||
name: string; | ||
isExported: boolean; | ||
isAsync: boolean; | ||
type?: string | undefined; | ||
@@ -22,3 +23,3 @@ start?: number | undefined; | ||
variables: VariableDeclaration[]; | ||
constructor(name: string, isExported: boolean, type?: string | undefined, start?: number | undefined, end?: number | undefined); | ||
constructor(name: string, isExported: boolean, isAsync: boolean, type?: string | undefined, start?: number | undefined, end?: number | undefined); | ||
} |
@@ -13,5 +13,6 @@ "use strict"; | ||
class FunctionDeclaration { | ||
constructor(name, isExported, type, start, end) { | ||
constructor(name, isExported, isAsync, type, start, end) { | ||
this.name = name; | ||
this.isExported = isExported; | ||
this.isAsync = isAsync; | ||
this.type = type; | ||
@@ -18,0 +19,0 @@ this.start = start; |
@@ -1,2 +0,2 @@ | ||
import { AbstractDeclaration, CallableDeclaration, ScopedDeclaration, TypedDeclaration } from './Declaration'; | ||
import { AbstractDeclaration, AsyncDeclaration, CallableDeclaration, OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration'; | ||
import { DeclarationVisibility } from './DeclarationVisibility'; | ||
@@ -15,3 +15,3 @@ import { ParameterDeclaration } from './ParameterDeclaration'; | ||
*/ | ||
export declare class MethodDeclaration implements AbstractDeclaration, CallableDeclaration, ScopedDeclaration, TypedDeclaration { | ||
export declare class MethodDeclaration implements AbstractDeclaration, AsyncDeclaration, CallableDeclaration, OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration { | ||
name: string; | ||
@@ -21,2 +21,5 @@ isAbstract: boolean; | ||
type: string | undefined; | ||
isOptional: boolean; | ||
isStatic: boolean; | ||
isAsync: boolean; | ||
start?: number | undefined; | ||
@@ -26,3 +29,3 @@ end?: number | undefined; | ||
variables: VariableDeclaration[]; | ||
constructor(name: string, isAbstract: boolean, visibility: DeclarationVisibility | undefined, type: string | undefined, start?: number | undefined, end?: number | undefined); | ||
constructor(name: string, isAbstract: boolean, visibility: DeclarationVisibility | undefined, type: string | undefined, isOptional: boolean, isStatic: boolean, isAsync: boolean, start?: number | undefined, end?: number | undefined); | ||
} |
@@ -14,3 +14,3 @@ "use strict"; | ||
class MethodDeclaration { | ||
constructor(name, isAbstract, visibility, type, start, end) { | ||
constructor(name, isAbstract, visibility, type, isOptional, isStatic, isAsync, start, end) { | ||
this.name = name; | ||
@@ -20,2 +20,5 @@ this.isAbstract = isAbstract; | ||
this.type = type; | ||
this.isOptional = isOptional; | ||
this.isStatic = isStatic; | ||
this.isAsync = isAsync; | ||
this.start = start; | ||
@@ -22,0 +25,0 @@ this.end = end; |
@@ -1,2 +0,2 @@ | ||
import { ScopedDeclaration, TypedDeclaration } from './Declaration'; | ||
import { OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration'; | ||
import { DeclarationVisibility } from './DeclarationVisibility'; | ||
@@ -11,9 +11,11 @@ /** | ||
*/ | ||
export declare class PropertyDeclaration implements ScopedDeclaration, TypedDeclaration { | ||
export declare class PropertyDeclaration implements OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration { | ||
name: string; | ||
visibility: DeclarationVisibility | undefined; | ||
type: string | undefined; | ||
isOptional: boolean; | ||
isStatic: boolean; | ||
start?: number | undefined; | ||
end?: number | undefined; | ||
constructor(name: string, visibility: DeclarationVisibility | undefined, type: string | undefined, start?: number | undefined, end?: number | undefined); | ||
constructor(name: string, visibility: DeclarationVisibility | undefined, type: string | undefined, isOptional: boolean, isStatic: boolean, start?: number | undefined, end?: number | undefined); | ||
} |
@@ -12,6 +12,8 @@ "use strict"; | ||
class PropertyDeclaration { | ||
constructor(name, visibility, type, start, end) { | ||
constructor(name, visibility, type, isOptional, isStatic, start, end) { | ||
this.name = name; | ||
this.visibility = visibility; | ||
this.type = type; | ||
this.isOptional = isOptional; | ||
this.isStatic = isStatic; | ||
this.start = start; | ||
@@ -18,0 +20,0 @@ this.end = end; |
@@ -54,3 +54,3 @@ "use strict"; | ||
} | ||
parent.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.getStart(), o.getEnd())); | ||
parent.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), !!o.questionToken, parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), o.getStart(), o.getEnd())); | ||
} | ||
@@ -92,6 +92,6 @@ else if (TypescriptGuards_1.isObjectBindingPattern(o.name) || TypescriptGuards_1.isArrayBindingPattern(o.name)) { | ||
if (o.modifiers) { | ||
classDeclaration.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.getStart(), o.getEnd())); | ||
classDeclaration.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), !!o.questionToken, parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), o.getStart(), o.getEnd())); | ||
} | ||
if (actualCount === classDeclaration.properties.length) { | ||
classDeclaration.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.getStart(), o.getEnd())); | ||
classDeclaration.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), !!o.questionToken, parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), o.getStart(), o.getEnd())); | ||
} | ||
@@ -101,6 +101,6 @@ return; | ||
if (TypescriptGuards_1.isGetAccessorDeclaration(o)) { | ||
classDeclaration.accessors.push(new AccessorDeclaration_1.GetterDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.modifiers !== undefined && o.modifiers.some(m => m.kind === typescript_1.SyntaxKind.AbstractKeyword), o.getStart(), o.getEnd())); | ||
classDeclaration.accessors.push(new AccessorDeclaration_1.GetterDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.modifiers !== undefined && o.modifiers.some(m => m.kind === typescript_1.SyntaxKind.AbstractKeyword), parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), o.getStart(), o.getEnd())); | ||
} | ||
if (TypescriptGuards_1.isSetAccessorDeclaration(o)) { | ||
classDeclaration.accessors.push(new AccessorDeclaration_1.SetterDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.modifiers !== undefined && o.modifiers.some(m => m.kind === typescript_1.SyntaxKind.AbstractKeyword), o.getStart(), o.getEnd())); | ||
classDeclaration.accessors.push(new AccessorDeclaration_1.SetterDeclaration(o.name.text, parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.modifiers !== undefined && o.modifiers.some(m => m.kind === typescript_1.SyntaxKind.AbstractKeyword), parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), o.getStart(), o.getEnd())); | ||
} | ||
@@ -114,3 +114,3 @@ if (TypescriptGuards_1.isConstructorDeclaration(o)) { | ||
else if (TypescriptGuards_1.isMethodDeclaration(o)) { | ||
const method = new MethodDeclaration_1.MethodDeclaration(o.name.text, o.modifiers !== undefined && o.modifiers.some(m => m.kind === typescript_1.SyntaxKind.AbstractKeyword), parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), o.getStart(), o.getEnd()); | ||
const method = new MethodDeclaration_1.MethodDeclaration(o.name.text, o.modifiers !== undefined && o.modifiers.some(m => m.kind === typescript_1.SyntaxKind.AbstractKeyword), parse_utilities_1.getNodeVisibility(o), parse_utilities_1.getNodeType(o.type), !!o.questionToken, parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.AsyncKeyword), o.getStart(), o.getEnd()); | ||
method.parameters = function_parser_1.parseMethodParams(o); | ||
@@ -117,0 +117,0 @@ classDeclaration.methods.push(method); |
@@ -91,3 +91,3 @@ "use strict"; | ||
const name = node.name ? node.name.text : parse_utilities_1.getDefaultResourceIdentifier(resource); | ||
const func = new FunctionDeclaration_1.FunctionDeclaration(name, parse_utilities_1.isNodeExported(node), parse_utilities_1.getNodeType(node.type), node.getStart(), node.getEnd()); | ||
const func = new FunctionDeclaration_1.FunctionDeclaration(name, parse_utilities_1.isNodeExported(node), parse_utilities_1.containsModifier(node, typescript_1.SyntaxKind.AsyncKeyword), parse_utilities_1.getNodeType(node.type), node.getStart(), node.getEnd()); | ||
if (parse_utilities_1.isNodeDefaultExported(node)) { | ||
@@ -94,0 +94,0 @@ func.isExported = false; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const typescript_1 = require("typescript"); | ||
const DefaultDeclaration_1 = require("../declarations/DefaultDeclaration"); | ||
@@ -28,6 +29,6 @@ const InterfaceDeclaration_1 = require("../declarations/InterfaceDeclaration"); | ||
if (TypescriptGuards_1.isPropertySignature(o)) { | ||
interfaceDeclaration.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, 2 /* Public */, parse_utilities_1.getNodeType(o.type), o.getStart(), o.getEnd())); | ||
interfaceDeclaration.properties.push(new PropertyDeclaration_1.PropertyDeclaration(o.name.text, 2 /* Public */, parse_utilities_1.getNodeType(o.type), !!o.questionToken, parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), o.getStart(), o.getEnd())); | ||
} | ||
else if (TypescriptGuards_1.isMethodSignature(o)) { | ||
const method = new MethodDeclaration_1.MethodDeclaration(o.name.text, true, 2 /* Public */, parse_utilities_1.getNodeType(o.type), o.getStart(), o.getEnd()); | ||
const method = new MethodDeclaration_1.MethodDeclaration(o.name.text, true, 2 /* Public */, parse_utilities_1.getNodeType(o.type), !!o.questionToken, parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.StaticKeyword), parse_utilities_1.containsModifier(o, typescript_1.SyntaxKind.AsyncKeyword), o.getStart(), o.getEnd()); | ||
method.parameters = function_parser_1.parseMethodParams(o); | ||
@@ -34,0 +35,0 @@ interfaceDeclaration.methods.push(method); |
@@ -1,2 +0,2 @@ | ||
import { Node, TypeNode } from 'typescript'; | ||
import { Node, SyntaxKind, TypeNode } from 'typescript'; | ||
import { DeclarationVisibility } from '../declarations/DeclarationVisibility'; | ||
@@ -31,2 +31,11 @@ import { Resource } from '../resources/Resource'; | ||
/** | ||
* Checks if a node contains a certain modifier (of a given kind) | ||
* | ||
* @export | ||
* @param {Node} node | ||
* @param {SyntaxKind} modifierKind | ||
* @returns {boolean} | ||
*/ | ||
export declare function containsModifier(node: Node, modifierKind: SyntaxKind): boolean; | ||
/** | ||
* Returns the enum value (visibility) of a node. | ||
@@ -33,0 +42,0 @@ * |
@@ -43,2 +43,16 @@ "use strict"; | ||
/** | ||
* Checks if a node contains a certain modifier (of a given kind) | ||
* | ||
* @export | ||
* @param {Node} node | ||
* @param {SyntaxKind} modifierKind | ||
* @returns {boolean} | ||
*/ | ||
function containsModifier(node, modifierKind) { | ||
if (!node.modifiers) | ||
return false; | ||
return node.modifiers.some(mod => mod.kind === modifierKind); | ||
} | ||
exports.containsModifier = containsModifier; | ||
/** | ||
* Returns the enum value (visibility) of a node. | ||
@@ -45,0 +59,0 @@ * |
{ | ||
"name": "typescript-parser", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.", | ||
@@ -39,14 +39,14 @@ "main": "index.js", | ||
"@smartive/tslint-config": "^4.0.0", | ||
"@types/jest": "^23.1.4", | ||
"@types/lodash-es": "^4.17.0", | ||
"@types/jest": "^23.3.1", | ||
"@types/lodash-es": "^4.17.1", | ||
"@types/mock-fs": "^3.6.30", | ||
"@types/node": "^10.5.1", | ||
"@types/node": "^10.9.4", | ||
"del-cli": "^1.1.0", | ||
"jest": "^23.3.0", | ||
"mock-fs": "^4.5.0", | ||
"semantic-release": "^15.6.3", | ||
"ts-jest": "^23.0.0", | ||
"tslint": "^5.10.0", | ||
"tsutils": "^2.27.2", | ||
"typedoc": "^0.11.1" | ||
"jest": "^23.5.0", | ||
"mock-fs": "^4.6.0", | ||
"semantic-release": "^15.9.12", | ||
"ts-jest": "^23.1.4", | ||
"tslint": "^5.11.0", | ||
"tsutils": "^3.0.0", | ||
"typedoc": "^0.12.0" | ||
}, | ||
@@ -57,4 +57,4 @@ "dependencies": { | ||
"tslib": "^1.9.3", | ||
"typescript": "^2.9.2" | ||
"typescript": "^3.0.3" | ||
} | ||
} |
@@ -19,3 +19,3 @@ import { getVisibilityText } from '../../declarations/DeclarationVisibility'; | ||
`${property.visibility !== undefined ? getVisibilityText(property.visibility) + ' ' : ''}` + | ||
`${property.name}${property.type ? `: ${property.type}` : ''};\n`; | ||
`${property.name}${property.isOptional ? '?' : ''}${property.type ? `: ${property.type}` : ''};\n`; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { AbstractDeclaration, ScopedDeclaration, TypedDeclaration } from './Declaration'; | ||
import { AbstractDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration'; | ||
import { DeclarationVisibility } from './DeclarationVisibility'; | ||
@@ -14,3 +14,7 @@ | ||
*/ | ||
export abstract class AccessorDeclaration implements ScopedDeclaration, TypedDeclaration, AbstractDeclaration { | ||
export abstract class AccessorDeclaration implements | ||
ScopedDeclaration, | ||
StaticDeclaration, | ||
TypedDeclaration, | ||
AbstractDeclaration { | ||
constructor( | ||
@@ -21,2 +25,3 @@ public name: string, | ||
public isAbstract: boolean, | ||
public isStatic: boolean, | ||
public start?: number, | ||
@@ -23,0 +28,0 @@ public end?: number, |
@@ -178,1 +178,52 @@ import { Node } from '../Node'; | ||
} | ||
/** | ||
* Interface for possible optional declarations. Contains information if the element is optional or not. | ||
* | ||
* @export | ||
* @interface OptionalDeclaration | ||
* @extends {Declaration} | ||
*/ | ||
export interface OptionalDeclaration extends Declaration { | ||
/** | ||
* Defines if the declaration is optional or not. | ||
* | ||
* @type {boolean} | ||
* @memberof OptionalDeclaration | ||
*/ | ||
isOptional: boolean; | ||
} | ||
/** | ||
* Interface for possible static declarations. | ||
* | ||
* @export | ||
* @interface StaticDeclaration | ||
* @extends {Declaration} | ||
*/ | ||
export interface StaticDeclaration extends Declaration { | ||
/** | ||
* Defines if the declaration is static or not. | ||
* | ||
* @type {boolean} | ||
* @memberof StaticDeclaration | ||
*/ | ||
isStatic: boolean; | ||
} | ||
/** | ||
* Interface for possible async declarations. | ||
* | ||
* @export | ||
* @interface AsyncDeclaration | ||
* @extends {Declaration} | ||
*/ | ||
export interface AsyncDeclaration extends Declaration { | ||
/** | ||
* Defines if the declaration is async or not. | ||
* | ||
* @type {boolean} | ||
* @memberof AsyncDeclaration | ||
*/ | ||
isAsync: boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { CallableDeclaration, ExportableDeclaration } from './Declaration'; | ||
import { AsyncDeclaration, CallableDeclaration, ExportableDeclaration } from './Declaration'; | ||
import { ParameterDeclaration } from './ParameterDeclaration'; | ||
@@ -14,3 +14,3 @@ import { VariableDeclaration } from './VariableDeclaration'; | ||
*/ | ||
export class FunctionDeclaration implements CallableDeclaration, ExportableDeclaration { | ||
export class FunctionDeclaration implements AsyncDeclaration, CallableDeclaration, ExportableDeclaration { | ||
public parameters: ParameterDeclaration[] = []; | ||
@@ -22,2 +22,3 @@ public variables: VariableDeclaration[] = []; | ||
public isExported: boolean, | ||
public isAsync: boolean, | ||
public type?: string, | ||
@@ -24,0 +25,0 @@ public start?: number, |
@@ -1,2 +0,10 @@ | ||
import { AbstractDeclaration, CallableDeclaration, ScopedDeclaration, TypedDeclaration } from './Declaration'; | ||
import { | ||
AbstractDeclaration, | ||
AsyncDeclaration, | ||
CallableDeclaration, | ||
OptionalDeclaration, | ||
ScopedDeclaration, | ||
StaticDeclaration, | ||
TypedDeclaration, | ||
} from './Declaration'; | ||
import { DeclarationVisibility } from './DeclarationVisibility'; | ||
@@ -16,3 +24,11 @@ import { ParameterDeclaration } from './ParameterDeclaration'; | ||
*/ | ||
export class MethodDeclaration implements AbstractDeclaration, CallableDeclaration, ScopedDeclaration, TypedDeclaration { | ||
export class MethodDeclaration implements | ||
AbstractDeclaration, | ||
AsyncDeclaration, | ||
CallableDeclaration, | ||
OptionalDeclaration, | ||
ScopedDeclaration, | ||
StaticDeclaration, | ||
TypedDeclaration { | ||
public parameters: ParameterDeclaration[] = []; | ||
@@ -26,2 +42,5 @@ public variables: VariableDeclaration[] = []; | ||
public type: string | undefined, | ||
public isOptional: boolean, | ||
public isStatic: boolean, | ||
public isAsync: boolean, | ||
public start?: number, | ||
@@ -28,0 +47,0 @@ public end?: number, |
@@ -1,2 +0,2 @@ | ||
import { ScopedDeclaration, TypedDeclaration } from './Declaration'; | ||
import { OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration'; | ||
import { DeclarationVisibility } from './DeclarationVisibility'; | ||
@@ -12,3 +12,3 @@ | ||
*/ | ||
export class PropertyDeclaration implements ScopedDeclaration, TypedDeclaration { | ||
export class PropertyDeclaration implements OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration { | ||
constructor( | ||
@@ -18,2 +18,4 @@ public name: string, | ||
public type: string | undefined, | ||
public isOptional: boolean, | ||
public isStatic: boolean, | ||
public start?: number, | ||
@@ -20,0 +22,0 @@ public end?: number, |
@@ -32,2 +32,3 @@ import { | ||
import { | ||
containsModifier, | ||
getDefaultResourceIdentifier, | ||
@@ -92,2 +93,4 @@ getNodeType, | ||
getNodeType(o.type), | ||
!!o.questionToken, | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
o.getStart(), | ||
@@ -142,2 +145,4 @@ o.getEnd(), | ||
getNodeType(o.type), | ||
!!o.questionToken, | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
o.getStart(), | ||
@@ -154,2 +159,4 @@ o.getEnd(), | ||
getNodeType(o.type), | ||
!!o.questionToken, | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
o.getStart(), | ||
@@ -170,2 +177,3 @@ o.getEnd(), | ||
o.modifiers !== undefined && o.modifiers.some(m => m.kind === SyntaxKind.AbstractKeyword), | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
o.getStart(), | ||
@@ -184,2 +192,3 @@ o.getEnd(), | ||
o.modifiers !== undefined && o.modifiers.some(m => m.kind === SyntaxKind.AbstractKeyword), | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
o.getStart(), | ||
@@ -202,2 +211,5 @@ o.getEnd(), | ||
getNodeType(o.type), | ||
!!o.questionToken, | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
containsModifier(o, SyntaxKind.AsyncKeyword), | ||
o.getStart(), | ||
@@ -204,0 +216,0 @@ o.getEnd(), |
@@ -33,3 +33,9 @@ import { | ||
import { parseIdentifier } from './identifier-parser'; | ||
import { getDefaultResourceIdentifier, getNodeType, isNodeDefaultExported, isNodeExported } from './parse-utilities'; | ||
import { | ||
containsModifier, | ||
getDefaultResourceIdentifier, | ||
getNodeType, | ||
isNodeDefaultExported, | ||
isNodeExported, | ||
} from './parse-utilities'; | ||
import { parseVariable } from './variable-parser'; | ||
@@ -141,3 +147,8 @@ | ||
const func = new TshFunction( | ||
name, isNodeExported(node), getNodeType(node.type), node.getStart(), node.getEnd(), | ||
name, | ||
isNodeExported(node), | ||
containsModifier(node, SyntaxKind.AsyncKeyword), | ||
getNodeType(node.type), | ||
node.getStart(), | ||
node.getEnd(), | ||
); | ||
@@ -144,0 +155,0 @@ if (isNodeDefaultExported(node)) { |
@@ -1,2 +0,2 @@ | ||
import { Identifier, InterfaceDeclaration } from 'typescript'; | ||
import { Identifier, InterfaceDeclaration, SyntaxKind } from 'typescript'; | ||
@@ -11,3 +11,9 @@ import { DeclarationVisibility } from '../declarations/DeclarationVisibility'; | ||
import { parseMethodParams } from './function-parser'; | ||
import { getDefaultResourceIdentifier, getNodeType, isNodeDefaultExported, isNodeExported } from './parse-utilities'; | ||
import { | ||
containsModifier, | ||
getDefaultResourceIdentifier, | ||
getNodeType, | ||
isNodeDefaultExported, | ||
isNodeExported, | ||
} from './parse-utilities'; | ||
@@ -41,2 +47,4 @@ /** | ||
getNodeType(o.type), | ||
!!o.questionToken, | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
o.getStart(), | ||
@@ -52,2 +60,5 @@ o.getEnd(), | ||
getNodeType(o.type), | ||
!!o.questionToken, | ||
containsModifier(o, SyntaxKind.StaticKeyword), | ||
containsModifier(o, SyntaxKind.AsyncKeyword), | ||
o.getStart(), | ||
@@ -54,0 +65,0 @@ o.getEnd(), |
@@ -1,2 +0,2 @@ | ||
import { getCombinedModifierFlags, ModifierFlags, Node, SyntaxKind, TypeNode } from 'typescript'; | ||
import { Declaration, getCombinedModifierFlags, ModifierFlags, Node, SyntaxKind, TypeNode } from 'typescript'; | ||
@@ -16,3 +16,3 @@ import { DeclarationVisibility } from '../declarations/DeclarationVisibility'; | ||
export function isNodeExported(node: Node): boolean { | ||
const flags = getCombinedModifierFlags(node); | ||
const flags = getCombinedModifierFlags(node as Declaration); | ||
return (flags & ModifierFlags.Export) === ModifierFlags.Export; | ||
@@ -30,3 +30,3 @@ } | ||
export function isNodeDefaultExported(node: Node): boolean { | ||
const flags = getCombinedModifierFlags(node); | ||
const flags = getCombinedModifierFlags(node as Declaration); | ||
return (flags & ModifierFlags.Default) === ModifierFlags.Default; | ||
@@ -47,2 +47,15 @@ } | ||
/** | ||
* Checks if a node contains a certain modifier (of a given kind) | ||
* | ||
* @export | ||
* @param {Node} node | ||
* @param {SyntaxKind} modifierKind | ||
* @returns {boolean} | ||
*/ | ||
export function containsModifier(node: Node, modifierKind: SyntaxKind): boolean { | ||
if (!node.modifiers) return false; | ||
return node.modifiers.some(mod => mod.kind === modifierKind); | ||
} | ||
/** | ||
* Returns the enum value (visibility) of a node. | ||
@@ -49,0 +62,0 @@ * |
293372
8084
+ Addedtypescript@3.9.10(transitive)
- Removedtypescript@2.9.2(transitive)
Updatedtypescript@^3.0.3