From b55fadd56f2cfd6168e36b5ec17f7d3b0375a06e Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Fri, 23 Dec 2016 09:53:38 -0600 Subject: [PATCH 01/11] Enable VS Code debugging, disable inline sources, pass through TSC grunt --- .baseDir.js.map | 2 +- .vscode/launch.json | 22 ++++++++ gruntfile.js | 2 +- index.js.map | 2 +- package.json | 4 +- tsconfig.json | 135 ++------------------------------------------ 6 files changed, 32 insertions(+), 135 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.baseDir.js.map b/.baseDir.js.map index bd62c82eb..c52053b69 100644 --- a/.baseDir.js.map +++ b/.baseDir.js.map @@ -1 +1 @@ -{"version":3,"file":".baseDir.js","sourceRoot":"","sources":["src/.baseDir.ts"],"names":[],"mappings":"","sourcesContent":["// Ignore this file. See https://github.com/grunt-ts/grunt-ts/issues/77"]} \ No newline at end of file +{"version":3,"file":".baseDir.js","sourceRoot":"","sources":["src/.baseDir.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..2ef92a671 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible Node.js debug attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceRoot}/bin/typedoc", + "args": [ + "--out", "tmp" + ], + "cwd": "${workspaceRoot}", + "outFiles": [ + "${workspaceRoot}/lib/**/*.js" + ], + "sourceMaps": true + } + ] +} \ No newline at end of file diff --git a/gruntfile.js b/gruntfile.js index fbf1a9519..08fd115e2 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -4,7 +4,7 @@ module.exports = function(grunt) pkg: grunt.file.readJSON('package.json'), ts: { typedoc: { - tsconfig: true + tsconfig: { passThrough: true } }, typescript: { options: { diff --git a/index.js.map b/index.js.map index 3ad40fcbe..1bb6062ea 100644 --- a/index.js.map +++ b/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,4BAA0B,mBAAmB,CAAC;AAAtC,gDAAsC;AAC9C,oBAA6B,WAAW,CAAC;AAAjC,8CAAiC;AAEzC,uBAAqC,oBAAoB,CAAC;AAAlD,mDAAe;AAAE,+BAAiC;AAC1D,yBAAgC,mCAAmC,CAAC;AAA5D,yDAA4D;AACpE,mBAA4B,gBAAgB,CAAC;AAArC,2CAAqC;AAC7C,wBAAgC,kCAAkC,CAAC;AAA3D,wDAA2D","sourcesContent":["export {Application} from \"./lib/application\";\nexport {CliApplication} from \"./lib/cli\";\n\nexport {EventDispatcher, Event} from \"./lib/utils/events\";\nexport {resetReflectionID} from \"./lib/models/reflections/abstract\";\nexport {normalizePath} from \"./lib/utils/fs\";\nexport {ProjectReflection} from \"./lib/models/reflections/project\";\n"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,iDAA8C;AAAtC,oCAAA,WAAW,CAAA;AACnB,iCAAyC;AAAjC,+BAAA,cAAc,CAAA;AAEtB,6CAA0D;AAAlD,mCAAA,eAAe,CAAA;AAAE,yBAAA,KAAK,CAAA;AAC9B,8DAAoE;AAA5D,uCAAA,iBAAiB,CAAA;AACzB,qCAA6C;AAArC,6BAAA,aAAa,CAAA;AACrB,4DAAmE;AAA3D,sCAAA,iBAAiB,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 0eb382f16..daefd4e51 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "progress": "^1.1.8", "shelljs": "^0.7.0", "typedoc-default-themes": "^0.4.0", - "typescript": "2.0.6" + "typescript": "2.1.4" }, "devDependencies": { "grunt": "^1.0.1", @@ -55,7 +55,7 @@ "grunt-contrib-watch": "^1.0.0", "grunt-mocha-istanbul": "^5.0.1", "grunt-string-replace": "^1.2.0", - "grunt-ts": "^5.3.0-beta.2", + "grunt-ts": "^5.5.1", "istanbul": "^0.4.1", "mocha": "^3.0.2" }, diff --git a/tsconfig.json b/tsconfig.json index e211d239c..fef4041ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,139 +7,14 @@ "preserveConstEnums": true, "declaration": true, "sourceMap": true, - "inlineSources": true, "outDir": "./", - "rootDir": "./src/", + "rootDir": "./src", "experimentalDecorators": true }, - "files": [ - "src/lib/application.ts", - "src/lib/cli.ts", - "src/lib/ts-internal.ts", - "src/lib/converter/components.ts", - "src/lib/converter/context.ts", - "src/lib/converter/convert-expression.ts", - "src/lib/converter/converter.ts", - "src/lib/converter/factories/comment.ts", - "src/lib/converter/factories/declaration.ts", - "src/lib/converter/factories/index.ts", - "src/lib/converter/factories/parameter.ts", - "src/lib/converter/factories/reference.ts", - "src/lib/converter/factories/signature.ts", - "src/lib/converter/factories/type-parameter.ts", - "src/lib/converter/index.ts", - "src/lib/converter/nodes/accessor.ts", - "src/lib/converter/nodes/alias.ts", - "src/lib/converter/nodes/block.ts", - "src/lib/converter/nodes/class.ts", - "src/lib/converter/nodes/constructor.ts", - "src/lib/converter/nodes/enum.ts", - "src/lib/converter/nodes/export.ts", - "src/lib/converter/nodes/function.ts", - "src/lib/converter/nodes/index.ts", - "src/lib/converter/nodes/interface.ts", - "src/lib/converter/nodes/literal-object.ts", - "src/lib/converter/nodes/literal-type.ts", - "src/lib/converter/nodes/module.ts", - "src/lib/converter/nodes/signature-call.ts", - "src/lib/converter/nodes/signature-index.ts", - "src/lib/converter/nodes/variable-statement.ts", - "src/lib/converter/nodes/variable.ts", - "src/lib/converter/plugins/CommentPlugin.ts", - "src/lib/converter/plugins/DecoratorPlugin.ts", - "src/lib/converter/plugins/DeepCommentPlugin.ts", - "src/lib/converter/plugins/DynamicModulePlugin.ts", - "src/lib/converter/plugins/GitHubPlugin.ts", - "src/lib/converter/plugins/GroupPlugin.ts", - "src/lib/converter/plugins/ImplementsPlugin.ts", - "src/lib/converter/plugins/PackagePlugin.ts", - "src/lib/converter/plugins/SourcePlugin.ts", - "src/lib/converter/plugins/TypePlugin.ts", - "src/lib/converter/plugins/index.ts", - "src/lib/converter/types/alias.ts", - "src/lib/converter/types/array.ts", - "src/lib/converter/types/binding-array.ts", - "src/lib/converter/types/binding-object.ts", - "src/lib/converter/types/enum.ts", - "src/lib/converter/types/index.ts", - "src/lib/converter/types/intrinsic.ts", - "src/lib/converter/types/reference.ts", - "src/lib/converter/types/string-literal.ts", - "src/lib/converter/types/tuple.ts", - "src/lib/converter/types/type-parameter.ts", - "src/lib/converter/types/union.ts", - "src/lib/converter/types/unknown.ts", - "src/lib/converter/utils/base-path.ts", - "src/lib/converter/utils/compiler-host.ts", - "src/lib/models/ReflectionGroup.ts", - "src/lib/models/comments/comment.ts", - "src/lib/models/comments/index.ts", - "src/lib/models/comments/tag.ts", - "src/lib/models/index.ts", - "src/lib/models/reflections/abstract.ts", - "src/lib/models/reflections/container.ts", - "src/lib/models/reflections/declaration.ts", - "src/lib/models/reflections/index.ts", - "src/lib/models/reflections/parameter.ts", - "src/lib/models/reflections/project.ts", - "src/lib/models/reflections/signature.ts", - "src/lib/models/reflections/type-parameter.ts", - "src/lib/models/sources/directory.ts", - "src/lib/models/sources/file.ts", - "src/lib/models/sources/index.ts", - "src/lib/models/types/abstract.ts", - "src/lib/models/types/index.ts", - "src/lib/models/types/intrinsic.ts", - "src/lib/models/types/reference.ts", - "src/lib/models/types/reflection.ts", - "src/lib/models/types/string-literal.ts", - "src/lib/models/types/tuple.ts", - "src/lib/models/types/type-parameter.ts", - "src/lib/models/types/union.ts", - "src/lib/models/types/unknown.ts", - "src/lib/output/components.ts", - "src/lib/output/events.ts", - "src/lib/output/helpers/compact.ts", - "src/lib/output/helpers/if-cond.ts", - "src/lib/output/helpers/if-signature.ts", - "src/lib/output/helpers/wbr.ts", - "src/lib/output/models/NavigationItem.ts", - "src/lib/output/models/UrlMapping.ts", - "src/lib/output/plugins/AssetsPlugin.ts", - "src/lib/output/plugins/JavascriptIndexPlugin.ts", - "src/lib/output/plugins/LayoutPlugin.ts", - "src/lib/output/plugins/MarkedLinksPlugin.ts", - "src/lib/output/plugins/MarkedPlugin.ts", - "src/lib/output/plugins/NavigationPlugin.ts", - "src/lib/output/plugins/PrettyPrintPlugin.ts", - "src/lib/output/plugins/TocPlugin.ts", - "src/lib/output/plugins/index.ts", - "src/lib/output/renderer.ts", - "src/lib/output/theme.ts", - "src/lib/output/themes/DefaultTheme.ts", - "src/lib/output/themes/MinimalTheme.ts", - "src/lib/output/utils/resources.ts", - "src/lib/output/utils/resources/helpers.ts", - "src/lib/output/utils/resources/stack.ts", - "src/lib/output/utils/resources/templates.ts", - "src/lib/utils/component.ts", - "src/lib/utils/events.ts", - "src/lib/utils/fs.ts", - "src/lib/utils/index.ts", - "src/lib/utils/loggers.ts", - "src/lib/utils/options/declaration.ts", - "src/lib/utils/options/help.ts", - "src/lib/utils/options/index.ts", - "src/lib/utils/options/options.ts", - "src/lib/utils/options/readers/arguments.ts", - "src/lib/utils/options/readers/index.ts", - "src/lib/utils/options/readers/tsconfig.ts", - "src/lib/utils/options/readers/typedoc.ts", - "src/lib/utils/options/sources/component.ts", - "src/lib/utils/options/sources/index.ts", - "src/lib/utils/options/sources/typescript.ts", - "src/lib/utils/plugins.ts", - "src/index.ts" + "include": [ + "src/**/*.ts" + ], + "exclude": [ ], "atom": { "rewriteTsconfig": true From fb3b4450eb4462f3c06ab04d6a1656f69cc6a5fa Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Fri, 23 Dec 2016 10:24:01 -0600 Subject: [PATCH 02/11] Fix compiler errors --- src/lib/converter/factories/declaration.ts | 12 ++++++------ src/lib/converter/nodes/class.ts | 2 +- src/lib/converter/nodes/constructor.ts | 4 ++-- src/lib/converter/nodes/variable-statement.ts | 4 ++-- src/lib/converter/types/binding-array.ts | 2 +- src/lib/converter/types/binding-object.ts | 2 +- src/lib/converter/types/reference.ts | 4 ++-- src/lib/converter/types/tuple.ts | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib/converter/factories/declaration.ts b/src/lib/converter/factories/declaration.ts index 981e25e65..dcdedabc7 100644 --- a/src/lib/converter/factories/declaration.ts +++ b/src/lib/converter/factories/declaration.ts @@ -54,9 +54,9 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection if (kind == ReflectionKind.ExternalModule) { isExported = true; // Always mark external modules as exported } else if (node.parent && node.parent.kind == ts.SyntaxKind.VariableDeclarationList) { - isExported = isExported || !!(node.parent.parent.flags & ts.NodeFlags.Export) + isExported = isExported || !!(node.parent.parent.flags & ts.ModifierFlags.Export) } else { - isExported = isExported || !!(node.flags & ts.NodeFlags.Export); + isExported = isExported || !!(node.flags & ts.ModifierFlags.Export); } if (!isExported && context.converter.excludeNotExported) { @@ -64,7 +64,7 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection } // Test whether the node is private, when inheriting ignore private members - var isPrivate = !!(node.flags & ts.NodeFlags.Private); + var isPrivate = !!(node.flags & ts.ModifierFlags.Private); if (context.isInherit && isPrivate) { return null; } @@ -73,7 +73,7 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection var isConstructorProperty:boolean = false; var isStatic = false; if (nonStaticKinds.indexOf(kind) == -1) { - isStatic = !!(node.flags & ts.NodeFlags.Static); + isStatic = !!(node.flags & ts.ModifierFlags.Static); if (container.kind == ReflectionKind.Class) { if (node.parent && node.parent.kind == ts.SyntaxKind.Constructor) { isConstructorProperty = true; @@ -127,8 +127,8 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection */ function setupDeclaration(context:Context, reflection:DeclarationReflection, node:ts.Node) { reflection.setFlag(ReflectionFlag.External, context.isExternal); - reflection.setFlag(ReflectionFlag.Protected, !!(node.flags & ts.NodeFlags.Protected)); - reflection.setFlag(ReflectionFlag.Public, !!(node.flags & ts.NodeFlags.Public)); + reflection.setFlag(ReflectionFlag.Protected, !!(node.flags & ts.ModifierFlags.Protected)); + reflection.setFlag(ReflectionFlag.Public, !!(node.flags & ts.ModifierFlags.Public)); reflection.setFlag(ReflectionFlag.Optional, !!(node['questionToken'])); if ( diff --git a/src/lib/converter/nodes/class.ts b/src/lib/converter/nodes/class.ts index 03563ab73..87aef8fff 100644 --- a/src/lib/converter/nodes/class.ts +++ b/src/lib/converter/nodes/class.ts @@ -36,7 +36,7 @@ export class ClassConverter extends ConverterNodeComponent context.withScope(reflection, node.typeParameters, () => { if (node.members) { node.members.forEach((member) => { - const privateMember = (member.flags & ts.NodeFlags.Private) > 0; + const privateMember = (member.flags & ts.ModifierFlags.Private) > 0; const exclude = context.converter.excludePrivate ? privateMember : false; if (!exclude) { diff --git a/src/lib/converter/nodes/constructor.ts b/src/lib/converter/nodes/constructor.ts index 5087359d8..18b44b7f1 100644 --- a/src/lib/converter/nodes/constructor.ts +++ b/src/lib/converter/nodes/constructor.ts @@ -62,10 +62,10 @@ export class ConstructorConverter extends ConverterNodeComponent { - this.owner.convertNode(context, element); + (node.elements as ts.BindingElement[]).forEach((element:ts.BindingElement) => { + this.owner.convertNode(context, element); if (_ts.isBindingPattern(element.name)) { this.convertBindingPattern(context, element.name); diff --git a/src/lib/converter/types/binding-array.ts b/src/lib/converter/types/binding-array.ts index 73d9042e5..f8bc2c0d1 100644 --- a/src/lib/converter/types/binding-array.ts +++ b/src/lib/converter/types/binding-array.ts @@ -26,7 +26,7 @@ export class BindingArrayConverter extends ConverterTypeComponent implements ITy convertNode(context:Context, node:ts.BindingPattern):Type { var types:Type[] = []; - node.elements.forEach((element) => { + (node.elements as ts.BindingElement[]).forEach((element) => { types.push(this.owner.convertType(context, element)); }); diff --git a/src/lib/converter/types/binding-object.ts b/src/lib/converter/types/binding-object.ts index 342d9a972..b29312a8c 100644 --- a/src/lib/converter/types/binding-object.ts +++ b/src/lib/converter/types/binding-object.ts @@ -33,7 +33,7 @@ export class BindingObjectConverter extends ConverterTypeComponent implements IT context.registerReflection(declaration, null); context.trigger(Converter.EVENT_CREATE_DECLARATION, declaration, node); context.withScope(declaration, () => { - node.elements.forEach((element) => { + (node.elements as ts.BindingElement[]).forEach((element) => { this.owner.convertNode(context, element); }); }); diff --git a/src/lib/converter/types/reference.ts b/src/lib/converter/types/reference.ts index 0fcfbc507..8434b7e65 100644 --- a/src/lib/converter/types/reference.ts +++ b/src/lib/converter/types/reference.ts @@ -23,7 +23,7 @@ export class ReferenceConverter extends ConverterTypeComponent implements ITypeN * Test whether this converter can handle the given TypeScript node. */ supportsNode(context:Context, node:ts.TypeReferenceNode, type:ts.TypeReference):boolean { - return !!(type.flags & ts.TypeFlags.ObjectType); + return !!(type.flags & ts.TypeFlags.Object); } @@ -31,7 +31,7 @@ export class ReferenceConverter extends ConverterTypeComponent implements ITypeN * Test whether this converter can handle the given TypeScript type. */ supportsType(context:Context, type:ts.TypeReference):boolean { - return !!(type.flags & ts.TypeFlags.ObjectType); + return !!(type.flags & ts.TypeFlags.Object); } diff --git a/src/lib/converter/types/tuple.ts b/src/lib/converter/types/tuple.ts index b39b98aab..c4e07d8f4 100644 --- a/src/lib/converter/types/tuple.ts +++ b/src/lib/converter/types/tuple.ts @@ -20,7 +20,7 @@ export class TupleConverter extends ConverterTypeComponent implements ITypeConve * Test whether this converter can handle the given TypeScript type. */ supportsType(context:Context, type:ts.TypeReference):boolean { - return !!(type.flags & ts.TypeFlags.Tuple); + return !!(type.objectFlags & ts.ObjectFlags.Tuple); } From ba102a60d4c7e4b63874e32f11060ea4ede85c89 Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Fri, 23 Dec 2016 10:24:11 -0600 Subject: [PATCH 03/11] Add VS Code build task --- .vscode/tasks.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..dbb12dd67 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,11 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "command": "tsc", + "isShellCommand": true, + "args": ["-w", "-p", "."], + "showOutput": "silent", + "isWatching": true, + "problemMatcher": "$tsc-watch" +} \ No newline at end of file From 9d7f258690de5747db2c099d1e62172633cf9385 Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Fri, 23 Dec 2016 11:32:54 -0600 Subject: [PATCH 04/11] Update TS internal (jsdoc) and guard undefined symbol declarations --- src/lib/converter/factories/comment.ts | 2 +- src/lib/converter/types/reference.ts | 4 ++-- src/lib/ts-internal.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/converter/factories/comment.ts b/src/lib/converter/factories/comment.ts index 88768189b..78f93175a 100644 --- a/src/lib/converter/factories/comment.ts +++ b/src/lib/converter/factories/comment.ts @@ -88,7 +88,7 @@ export function getRawComment(node:ts.Node):string { } var sourceFile = _ts.getSourceFileOfNode(node); - var comments = _ts.getJsDocComments(node, sourceFile); + var comments = _ts.getJSDocCommentRanges(node, sourceFile.text); if (comments && comments.length) { var comment:ts.CommentRange; if (node.kind == ts.SyntaxKind.SourceFile) { diff --git a/src/lib/converter/types/reference.ts b/src/lib/converter/types/reference.ts index 8434b7e65..e7e7b1ac2 100644 --- a/src/lib/converter/types/reference.ts +++ b/src/lib/converter/types/reference.ts @@ -51,7 +51,7 @@ export class ReferenceConverter extends ConverterTypeComponent implements ITypeN * @returns The type reflection representing the given reference node. */ convertNode(context:Context, node:ts.TypeReferenceNode, type:ts.TypeReference):Type { - if (!type.symbol) { + if (!type.symbol || !type.symbol.declarations) { return new IntrinsicType('Object'); } else if (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral) { return this.convertLiteral(context, type.symbol, node); @@ -81,7 +81,7 @@ export class ReferenceConverter extends ConverterTypeComponent implements ITypeN * @returns The type reflection representing the given type reference. */ convertType(context:Context, type:ts.TypeReference):Type { - if (!type.symbol) { + if (!type.symbol || !type.symbol.declarations) { return new IntrinsicType('Object'); } else if (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral) { return this.convertLiteral(context, type.symbol); diff --git a/src/lib/ts-internal.ts b/src/lib/ts-internal.ts index 598fa2dd3..30196b302 100644 --- a/src/lib/ts-internal.ts +++ b/src/lib/ts-internal.ts @@ -78,9 +78,9 @@ export function declarationNameToString(name: ts.DeclarationName): string { return tsany.declarationNameToString.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L598 -export function getJsDocComments(node: ts.Node, sourceFileOfNode: ts.SourceFile) { - return tsany.getJsDocComments.apply(this, arguments); +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L1423 +export function getJSDocCommentRanges(node: ts.Node, text: string) { + return tsany.getJSDocCommentRanges.apply(this, arguments); } // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1487 From b97de67b06ac3f5f4d92f14ad09c86d67693851c Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Fri, 23 Dec 2016 11:43:03 -0600 Subject: [PATCH 05/11] Debug tests --- .vscode/launch.json | 5 +---- tsconfig.json | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 2ef92a671..3f70a3dd1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,10 +8,7 @@ "type": "node", "request": "launch", "name": "Launch Program", - "program": "${workspaceRoot}/bin/typedoc", - "args": [ - "--out", "tmp" - ], + "program": "${workspaceRoot}/node_modules/mocha/bin/mocha", "cwd": "${workspaceRoot}", "outFiles": [ "${workspaceRoot}/lib/**/*.js" diff --git a/tsconfig.json b/tsconfig.json index fef4041ef..4bc2cf09e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "preserveConstEnums": true, "declaration": true, "sourceMap": true, + "sourceRoot": "src", "outDir": "./", "rootDir": "./src", "experimentalDecorators": true From 1330243f6c3ba27a8055e4a800005caf546c34e3 Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Fri, 23 Dec 2016 11:43:11 -0600 Subject: [PATCH 06/11] Update launch json --- .vscode/launch.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3f70a3dd1..3d6f41e78 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,10 +8,14 @@ "type": "node", "request": "launch", "name": "Launch Program", - "program": "${workspaceRoot}/node_modules/mocha/bin/mocha", + "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", "cwd": "${workspaceRoot}", + "args": [ + "--no-timeouts" + ], "outFiles": [ - "${workspaceRoot}/lib/**/*.js" + "${workspaceRoot}/lib/**/*.js", + "${workspaceRoot}/test/**/*.js" ], "sourceMaps": true } From 031c4b902f87752b032f45366b9df31493c31454 Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Sun, 25 Dec 2016 10:08:49 -0600 Subject: [PATCH 07/11] Fix checking modifier flags, null symbol decs --- src/lib/converter/factories/declaration.ts | 17 +++++++++++------ src/lib/converter/types/reference.ts | 8 ++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/lib/converter/factories/declaration.ts b/src/lib/converter/factories/declaration.ts index dcdedabc7..f0624eeda 100644 --- a/src/lib/converter/factories/declaration.ts +++ b/src/lib/converter/factories/declaration.ts @@ -43,6 +43,8 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection } } + var modifiers = ts.getCombinedModifierFlags(node); + // Test whether the node is exported var isExported:boolean; if (container.kindOf([ReflectionKind.Module, ReflectionKind.ExternalModule])) { @@ -54,9 +56,10 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection if (kind == ReflectionKind.ExternalModule) { isExported = true; // Always mark external modules as exported } else if (node.parent && node.parent.kind == ts.SyntaxKind.VariableDeclarationList) { - isExported = isExported || !!(node.parent.parent.flags & ts.ModifierFlags.Export) + var parentModifiers = ts.getCombinedModifierFlags(node.parent.parent); + isExported = isExported || !!(parentModifiers & ts.ModifierFlags.Export) } else { - isExported = isExported || !!(node.flags & ts.ModifierFlags.Export); + isExported = isExported || !!(modifiers & ts.ModifierFlags.Export); } if (!isExported && context.converter.excludeNotExported) { @@ -64,7 +67,7 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection } // Test whether the node is private, when inheriting ignore private members - var isPrivate = !!(node.flags & ts.ModifierFlags.Private); + var isPrivate = !!(modifiers & ts.ModifierFlags.Private); if (context.isInherit && isPrivate) { return null; } @@ -73,7 +76,7 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection var isConstructorProperty:boolean = false; var isStatic = false; if (nonStaticKinds.indexOf(kind) == -1) { - isStatic = !!(node.flags & ts.ModifierFlags.Static); + isStatic = !!(modifiers & ts.ModifierFlags.Static); if (container.kind == ReflectionKind.Class) { if (node.parent && node.parent.kind == ts.SyntaxKind.Constructor) { isConstructorProperty = true; @@ -126,9 +129,11 @@ export function createDeclaration(context:Context, node:ts.Node, kind:Reflection * @returns The reflection populated with the values of the given node. */ function setupDeclaration(context:Context, reflection:DeclarationReflection, node:ts.Node) { + var modifiers = ts.getCombinedModifierFlags(node); + reflection.setFlag(ReflectionFlag.External, context.isExternal); - reflection.setFlag(ReflectionFlag.Protected, !!(node.flags & ts.ModifierFlags.Protected)); - reflection.setFlag(ReflectionFlag.Public, !!(node.flags & ts.ModifierFlags.Public)); + reflection.setFlag(ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected)); + reflection.setFlag(ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public)); reflection.setFlag(ReflectionFlag.Optional, !!(node['questionToken'])); if ( diff --git a/src/lib/converter/types/reference.ts b/src/lib/converter/types/reference.ts index e7e7b1ac2..c31bd2ba7 100644 --- a/src/lib/converter/types/reference.ts +++ b/src/lib/converter/types/reference.ts @@ -51,9 +51,9 @@ export class ReferenceConverter extends ConverterTypeComponent implements ITypeN * @returns The type reflection representing the given reference node. */ convertNode(context:Context, node:ts.TypeReferenceNode, type:ts.TypeReference):Type { - if (!type.symbol || !type.symbol.declarations) { + if (!type.symbol) { return new IntrinsicType('Object'); - } else if (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral) { + } else if (type.symbol.declarations && (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral)) { return this.convertLiteral(context, type.symbol, node); } @@ -81,9 +81,9 @@ export class ReferenceConverter extends ConverterTypeComponent implements ITypeN * @returns The type reflection representing the given type reference. */ convertType(context:Context, type:ts.TypeReference):Type { - if (!type.symbol || !type.symbol.declarations) { + if (!type.symbol) { return new IntrinsicType('Object'); - } else if (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral) { + } else if (type.symbol.declarations && (type.symbol.flags & ts.SymbolFlags.TypeLiteral || type.symbol.flags & ts.SymbolFlags.ObjectLiteral)) { return this.convertLiteral(context, type.symbol); } From f3209dd8e6ed419ab529e9dce6e0510866954b52 Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Sun, 25 Dec 2016 10:40:08 -0600 Subject: [PATCH 08/11] Fix more modifier detection --- src/lib/converter/nodes/class.ts | 3 ++- src/lib/converter/nodes/constructor.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/converter/nodes/class.ts b/src/lib/converter/nodes/class.ts index 87aef8fff..4f35dbbc7 100644 --- a/src/lib/converter/nodes/class.ts +++ b/src/lib/converter/nodes/class.ts @@ -36,7 +36,8 @@ export class ClassConverter extends ConverterNodeComponent context.withScope(reflection, node.typeParameters, () => { if (node.members) { node.members.forEach((member) => { - const privateMember = (member.flags & ts.ModifierFlags.Private) > 0; + const modifiers = ts.getCombinedModifierFlags(member); + const privateMember = (modifiers & ts.ModifierFlags.Private) > 0; const exclude = context.converter.excludePrivate ? privateMember : false; if (!exclude) { diff --git a/src/lib/converter/nodes/constructor.ts b/src/lib/converter/nodes/constructor.ts index 18b44b7f1..90ad261ce 100644 --- a/src/lib/converter/nodes/constructor.ts +++ b/src/lib/converter/nodes/constructor.ts @@ -62,10 +62,11 @@ export class ConstructorConverter extends ConverterNodeComponent Date: Sun, 25 Dec 2016 10:46:59 -0600 Subject: [PATCH 09/11] Remove sourceroot --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 4bc2cf09e..fef4041ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,6 @@ "preserveConstEnums": true, "declaration": true, "sourceMap": true, - "sourceRoot": "src", "outDir": "./", "rootDir": "./src", "experimentalDecorators": true From 19d184436d095c90514d094f96b2faf2690ea878 Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Sun, 25 Dec 2016 11:20:30 -0600 Subject: [PATCH 10/11] Update ts internal API --- src/lib/ts-internal.ts | 55 ++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/src/lib/ts-internal.ts b/src/lib/ts-internal.ts index 30196b302..5a96abb1b 100644 --- a/src/lib/ts-internal.ts +++ b/src/lib/ts-internal.ts @@ -6,18 +6,18 @@ const tsany = ts as any; */ declare module "typescript" { interface Symbol { - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2166 + // https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/types.ts#L2658 id?: number; - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2168 + // https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/types.ts#L2660 parent?: ts.Symbol; } interface Node { - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L469 + // https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/types.ts#L497 symbol?: ts.Symbol; - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L472 + // https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/types.ts#L500 localSymbol?: ts.Symbol; - // https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L471 + // https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/types.ts#L499 nextContainer?: ts.Node; } } @@ -25,55 +25,54 @@ declare module "typescript" { /** * These functions are in "core" and are marked as @internal: - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L4-L5 + * https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/core.ts#L9-L10 */ -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L655-L656 -export function createCompilerDiagnostic(message: ts.DiagnosticMessage, ...args: any[]): ts.Diagnostic; +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/core.ts#L1133-LL1134 +export function createCompilerDiagnostic(message: ts.DiagnosticMessage, ...args: (string | number)[]): ts.Diagnostic; export function createCompilerDiagnostic(message: ts.DiagnosticMessage): ts.Diagnostic; export function createCompilerDiagnostic() { return tsany.createCompilerDiagnostic.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L701 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/core.ts#L1191 export function compareValues(a: T, b: T): number { return tsany.compareValues.apply(this, arguments); // Actually returns a ts.Comparison which is also internal } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L790 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/core.ts#L1281 export function normalizeSlashes(path: string): string { return tsany.normalizeSlashes.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L795 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/core.ts#L1288 export function getRootLength(path: string): number { return tsany.getRootLength.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/core.ts#L852-L854 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/core.ts#L1368-L1370 export function getDirectoryPath(path: ts.Path): ts.Path; export function getDirectoryPath(path: string): string; -export function getDirectoryPath(path: string): any; export function getDirectoryPath() { return tsany.getDirectoryPath.apply(this, arguments); } /** * These functions are in "utilities" and are marked as @internal: - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L3-L4 + * https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L3-L4 */ -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L188 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L152 export function getSourceFileOfNode(node: ts.Node): ts.SourceFile { return tsany.getSourceFileOfNode.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L333 -export function getTextOfNode(node: ts.Node, includeTrivia?: boolean): string { +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L301 +export function getTextOfNode(node: ts.Node, includeTrivia = false): string { return tsany.getTextOfNode.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L438 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L473 export function declarationNameToString(name: ts.DeclarationName): string { return tsany.declarationNameToString.apply(this, arguments); } @@ -83,28 +82,28 @@ export function getJSDocCommentRanges(node: ts.Node, text: string) { return tsany.getJSDocCommentRanges.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1487 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L3738 export function isBindingPattern(node: ts.Node): node is ts.BindingPattern { return tsany.isBindingPattern.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1696 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L1729 export function getClassExtendsHeritageClauseElement(node: ts.ClassLikeDeclaration | ts.InterfaceDeclaration) { return tsany.getClassExtendsHeritageClauseElement.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1701 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L1734 export function getClassImplementsHeritageClauseElements(node: ts.ClassLikeDeclaration) { return tsany.getClassImplementsHeritageClauseElements.apply(this, arguments); } -// https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/utilities.ts#L1706 +// https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L1739 export function getInterfaceBaseTypeNodes(node: ts.InterfaceDeclaration) { return tsany.getInterfaceBaseTypeNodes.apply(this, arguments); } /** - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2789-L2924 + * https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/types.ts#L3347 * This is large enum of char codes. * * Faking the enum as a var (only certain codes are used by TypeDoc) @@ -117,18 +116,12 @@ export const CharacterCodes: { at: number; } = tsany.CharacterCodes; -/** - * https://github.com/Microsoft/TypeScript/blob/v2.0.5/src/compiler/types.ts#L2334 - * Duplicating the interface definition :( - */ -// interface IntrinsicType extends ts.Type { -// intrinsicName: string; -// } - export const optionDeclarations: CommandLineOption[] = tsany.optionDeclarations; /** * Command line options + * + * https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/types.ts#L3344 */ export interface CommandLineOption { name: string; From 2b8d0657c5405052f5b90439c1fa1359e6e3c3ae Mon Sep 17 00:00:00 2001 From: Kamran Ayub Date: Sun, 25 Dec 2016 12:10:07 -0600 Subject: [PATCH 11/11] Inline sources for npm install-based debugging --- index.js.map | 2 +- tsconfig.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js.map b/index.js.map index 1bb6062ea..c3df7d613 100644 --- a/index.js.map +++ b/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,iDAA8C;AAAtC,oCAAA,WAAW,CAAA;AACnB,iCAAyC;AAAjC,+BAAA,cAAc,CAAA;AAEtB,6CAA0D;AAAlD,mCAAA,eAAe,CAAA;AAAE,yBAAA,KAAK,CAAA;AAC9B,8DAAoE;AAA5D,uCAAA,iBAAiB,CAAA;AACzB,qCAA6C;AAArC,6BAAA,aAAa,CAAA;AACrB,4DAAmE;AAA3D,sCAAA,iBAAiB,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,iDAA8C;AAAtC,oCAAA,WAAW,CAAA;AACnB,iCAAyC;AAAjC,+BAAA,cAAc,CAAA;AAEtB,6CAA0D;AAAlD,mCAAA,eAAe,CAAA;AAAE,yBAAA,KAAK,CAAA;AAC9B,8DAAoE;AAA5D,uCAAA,iBAAiB,CAAA;AACzB,qCAA6C;AAArC,6BAAA,aAAa,CAAA;AACrB,4DAAmE;AAA3D,sCAAA,iBAAiB,CAAA","sourcesContent":["export {Application} from \"./lib/application\";\r\nexport {CliApplication} from \"./lib/cli\";\r\n\r\nexport {EventDispatcher, Event} from \"./lib/utils/events\";\r\nexport {resetReflectionID} from \"./lib/models/reflections/abstract\";\r\nexport {normalizePath} from \"./lib/utils/fs\";\r\nexport {ProjectReflection} from \"./lib/models/reflections/project\";\r\n"]} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index fef4041ef..0987251cc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "preserveConstEnums": true, "declaration": true, "sourceMap": true, + "inlineSources": true, // required for debugging for npm installs "outDir": "./", "rootDir": "./src", "experimentalDecorators": true