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

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 .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ matrix:

environment:
matrix:
- nodejs_version: "10"
- nodejs_version: "9"
- nodejs_version: "8"

Expand Down
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ notifications:

jobs:
include:
- stage: test
node_js: '10'
after_success:
- npm i -g codecov
- codecov
- stage: test
node_js: '9'
after_success:
Expand All @@ -25,14 +30,14 @@ jobs:
- npm i -g codecov
- codecov
- stage: deploy
node_js: '9'
node_js: '10'
script: npm run typedoc
deploy:
provider: pages
skip_cleanup: true
github_token: $GH_TOKEN
local_dir: ./docs
- stage: deploy
node_js: '9'
node_js: '10'
before_script: npm run build
script: npm run semantic-release
2 changes: 1 addition & 1 deletion config/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"declaration": true,
"sourceMap": false,
"importHelpers": true,
"strictNullChecks": true,
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noUnusedLocals": true,
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@
"homepage": "https://github.com/TypeScript-Heroes/node-typescript-parser#readme",
"devDependencies": {
"@smartive/tslint-config": "^3.0.1",
"@types/jest": "^22.2.2",
"@types/jest": "^23.1.2",
"@types/lodash-es": "^4.17.0",
"@types/mock-fs": "^3.6.30",
"@types/node": "^9.6.2",
"@types/node": "^10.3.6",
"del-cli": "^1.1.0",
"jest": "^22.4.3",
"mock-fs": "^4.4.2",
"semantic-release": "^15.1.5",
"ts-jest": "^22.4.2",
"tslint": "^5.9.1",
"tsutils": "^2.26.0",
"jest": "^23.2.0",
"mock-fs": "^4.5.0",
"semantic-release": "^15.6.0",
"ts-jest": "^22.4.6",
"tslint": "^5.10.0",
"tsutils": "^2.27.1",
"typedoc": "^0.11.1"
},
"dependencies": {
"lodash": "^4.17.5",
"lodash-es": "^4.17.8",
"tslib": "^1.9.0",
"typescript": "^2.8.1"
"lodash": "^4.17.10",
"lodash-es": "^4.17.10",
"tslib": "^1.9.3",
"typescript": "^2.9.2"
}
}
3 changes: 3 additions & 0 deletions src/DeclarationIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ export class DeclarationIndex {
): void {
exportedLib.declarations
.forEach((o) => {
if (!tsExport.specifiers) {
return;
}
const ex = tsExport.specifiers.find(s => s.specifier === o.name);
if (!ex) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/code-generators/TypescriptCodeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type Generators = { [name: string]: (generatable: Generatable, options: T
* Hash with all possible (yet implemented) generators.
*/
export const GENERATORS: Generators = {
[SymbolSpecifier.name]: generateSymbolSpecifier,
[SymbolSpecifier.name]: generateSymbolSpecifier as any,
[MethodDeclaration.name]: generateMethodDeclaration,
[ParameterDeclaration.name]: generateParameterDeclaration,
[PropertyDeclaration.name]: generatePropertyDeclaration,
Expand Down
2 changes: 1 addition & 1 deletion src/declarations/ClassDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PropertyDeclaration } from './PropertyDeclaration';
* @implements {GenericDeclaration}
*/
export class ClassDeclaration implements ClassLikeDeclaration, ExportableDeclaration, GenericDeclaration {
public ctor: ConstructorDeclaration;
public ctor: ConstructorDeclaration | undefined;
public accessors: AccessorDeclaration[] = [];
public properties: PropertyDeclaration[] = [];
public methods: MethodDeclaration[] = [];
Expand Down
6 changes: 3 additions & 3 deletions src/declarations/DefaultDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { Declaration, ExportableDeclaration } from './Declaration';
* Default declaration. Is used when a file exports something as its default.
* Primary use is to ask the user about a name for the default export.
* Is kind of an abstract declaration since there is no real declaration.
*
*
* @export
* @class DefaultDeclaration
* @implements {ExportableDeclaration}
*/
export class DefaultDeclaration implements ExportableDeclaration {
public readonly isExported: boolean = true;

private exported: Declaration;
private exported: Declaration | undefined;

public get exportedDeclaration(): Declaration {
if (!this.exported) {
this.exported = this.resource.declarations.find(o => o.name === this.name) !;
this.exported = this.resource.declarations.find(o => o.name === this.name)!;
}

return this.exported;
Expand Down
2 changes: 1 addition & 1 deletion src/declarations/InterfaceDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { PropertyDeclaration } from './PropertyDeclaration';
* @implements {GenericDeclaration}
*/
export class InterfaceDeclaration implements ClassLikeDeclaration, ExportableDeclaration, GenericDeclaration {
public accessors: AccessorDeclaration[];
public accessors: AccessorDeclaration[] = [];
public typeParameters: string[] | undefined;
public properties: PropertyDeclaration[] = [];
public methods: MethodDeclaration[] = [];
Expand Down
4 changes: 2 additions & 2 deletions src/exports/NamedExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { Export } from './Export';

/**
* Declares a named export (i.e. export { Foobar } from ...).
*
*
* @export
* @class NamedExport
* @implements {Export}
*/
export class NamedExport implements Export {
public specifiers: SymbolSpecifier[];
public specifiers: SymbolSpecifier[] | undefined;

constructor(public start: number, public end: number, public from: string) { }
}
5 changes: 2 additions & 3 deletions src/node-parser/class-parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
ArrayBindingPattern,
BindingElement,
ClassDeclaration,
ConstructorDeclaration,
Identifier,
Expand Down Expand Up @@ -96,8 +95,8 @@ export function parseCtorParams(
} else if (isObjectBindingPattern(o.name) || isArrayBindingPattern(o.name)) {
const identifiers = o.name as ObjectBindingPattern | ArrayBindingPattern;
const elements = [...identifiers.elements];

ctor.parameters = ctor.parameters.concat(<TshParameter[]>elements.map((bind: BindingElement) => {
// TODO: BindingElement
ctor.parameters = ctor.parameters.concat(<TshParameter[]>elements.map((bind: any) => {
if (isIdentifier(bind.name)) {
return new TshParameter(
(bind.name as Identifier).text, undefined, bind.getStart(), bind.getEnd(),
Expand Down
13 changes: 6 additions & 7 deletions src/node-parser/function-parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
ArrayBindingPattern,
BindingElement,
FunctionDeclaration,
Identifier,
MethodDeclaration,
Expand All @@ -26,7 +25,7 @@ import { parseVariable } from './variable-parser';
/**
* Parse the parts of a function. All functions / methods contain various information about used variables
* and parameters.
*
*
* @export
* @param {Resource} resource
* @param {(TshConstructor | TshMethod | TshFunction)} parent
Expand All @@ -53,8 +52,8 @@ export function parseFunctionParts(
}

/**
* Parse method parameters.
*
* Parse method parameters.
*
* @export
* @param {(FunctionDeclaration | MethodDeclaration | MethodSignature)} node
* @returns {TshParameter[]}
Expand All @@ -72,8 +71,8 @@ export function parseMethodParams(
} else if (isObjectBindingPattern(cur.name) || isArrayBindingPattern(cur.name)) {
const identifiers = cur.name as ObjectBindingPattern | ArrayBindingPattern;
const elements = [...identifiers.elements];

params = params.concat(<TshParameter[]>elements.map((o: BindingElement) => {
// TODO: BindingElement
params = params.concat(<TshParameter[]>elements.map((o: any) => {
if (isIdentifier(o.name)) {
return new TshParameter(
(o.name as Identifier).text, undefined, o.getStart(), o.getEnd(),
Expand All @@ -90,7 +89,7 @@ export function parseMethodParams(
/**
* Parses a function into its declaration.
* Parses the functions sub information like parameters and variables.
*
*
* @export
* @param {Resource} resource
* @param {FunctionDeclaration} node
Expand Down
4 changes: 2 additions & 2 deletions src/node-parser/identifier-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const usageAllowedIfLast = [
SyntaxKind.BinaryExpression,
];

const usagePredicates: any = [
(o: Node) => o.parent && usageNotAllowedParents.indexOf(o.parent.kind) === -1,
const usagePredicates: ((node: Node) => boolean)[] = [
(o: Node) => o.parent !== undefined && usageNotAllowedParents.indexOf(o.parent.kind) === -1,
allowedIfLastIdentifier,
allowedIfPropertyAccessFirst,
];
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/TypescriptParser.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ Array [

exports[`TypescriptParser Declaration parsing Interfaces should parse a non exported interface 1`] = `
InterfaceDeclaration {
"accessors": Array [],
"end": 130,
"isExported": false,
"methods": Array [
Expand Down Expand Up @@ -467,6 +468,7 @@ InterfaceDeclaration {

exports[`TypescriptParser Declaration parsing Interfaces should parse an exported interface 1`] = `
InterfaceDeclaration {
"accessors": Array [],
"end": 286,
"isExported": true,
"methods": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports[`DeclarationIndex - specific case "reindex-with-global-module" should pa
Array [
DeclarationInfo {
"declaration": InterfaceDeclaration {
"accessors": Array [],
"end": 70,
"isExported": true,
"methods": Array [],
Expand Down