fix(Typings): Output public constructors in .d.ts files
Closes #3926. Closes #3963
This commit is contained in:
parent
12dd44f7f6
commit
1926335b85
|
@ -52,11 +52,9 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
|
|||
id: 'angular2/angular2',
|
||||
references: ['../es6-promise/es6-promise.d.ts', '../rx/rx.d.ts'],
|
||||
modules: {
|
||||
'angular2/angular2': {namespace: 'ng', id: 'angular2/angular2'}
|
||||
/* TODO(jeffbcross): re-implement with @jteplitz as part of #3926,
|
||||
'angular2/angular2': {namespace: 'ng', id: 'angular2/angular2'},
|
||||
'angular2/web_worker/worker': {namespace: 'ngWorker', id: 'angular2/web_worker/worker'},
|
||||
'angular2/web_worker/ui': {namespace: 'ngUi', id: 'angular2/web_worker/ui'}
|
||||
*/
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ function DtsSerializer(remap) {
|
|||
}
|
||||
|
||||
DtsSerializer.prototype = {
|
||||
_initializerRegex: /\s*=[^>][^,}]*/g,
|
||||
|
||||
constructor: DtsSerializer,
|
||||
|
||||
|
@ -18,15 +19,21 @@ DtsSerializer.prototype = {
|
|||
}
|
||||
if (ast.parameters) {
|
||||
buffer.push('(');
|
||||
buffer.push(ast.parameters.join(', '));
|
||||
var parameters = ast.parameters;
|
||||
for (var i = 0; i < parameters.length; i++) {
|
||||
parameters[i] = parameters[i].replace(this._initializerRegex, '');
|
||||
}
|
||||
buffer.push(parameters.join(', '));
|
||||
buffer.push(')');
|
||||
}
|
||||
if (ast.returnType) {
|
||||
buffer.push(': ', ast.returnType);
|
||||
} else if (ast.parameters) {
|
||||
buffer.push(': void');
|
||||
} else {
|
||||
buffer.push(': any');
|
||||
if (!isConstructor(ast)) {
|
||||
if (ast.returnType) {
|
||||
buffer.push(': ', ast.returnType);
|
||||
} else if (ast.parameters) {
|
||||
buffer.push(': void');
|
||||
} else {
|
||||
buffer.push(': any');
|
||||
}
|
||||
}
|
||||
buffer.push(';\n');
|
||||
},
|
||||
|
@ -58,6 +65,7 @@ DtsSerializer.prototype = {
|
|||
buffer.indent();
|
||||
if (ast.newMember) this.member(buffer, ast.newMember);
|
||||
if (ast.callMember) this.member(buffer, ast.callMember);
|
||||
if (ast.constructorDoc) this.member(buffer, ast.constructorDoc);
|
||||
|
||||
ast.statics.forEach(function(staticMember) {
|
||||
this.member(buffer, staticMember);
|
||||
|
@ -144,7 +152,6 @@ DtsSerializer.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
function Buffer() {
|
||||
this._globalBuffer = [];
|
||||
this._indentedBuffer = [];
|
||||
|
@ -191,7 +198,11 @@ Buffer.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
function isConstructor(ast) {
|
||||
return ast.parameters && ast.name === "constructor";
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
DtsSerializer: DtsSerializer
|
||||
};
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||
function createExportDoc(name, exportSymbol, moduleDoc, basePath, typeChecker) {
|
||||
var typeParamString = '';
|
||||
var heritageString = '';
|
||||
var typeDefinition = '';
|
||||
|
||||
exportSymbol.declarations.forEach(function(decl) {
|
||||
var sourceFile = ts.getSourceFileOfNode(decl);
|
||||
|
@ -158,6 +159,10 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||
typeParamString = '<' + getText(sourceFile, decl.typeParameters) + '>';
|
||||
}
|
||||
|
||||
if (decl.symbol.flags & ts.SymbolFlags.TypeAlias) {
|
||||
typeDefinition = getText(sourceFile, decl.type);
|
||||
}
|
||||
|
||||
if (decl.heritageClauses) {
|
||||
decl.heritageClauses.forEach(function(heritage) {
|
||||
|
||||
|
@ -215,6 +220,9 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||
if(exportSymbol.flags & ts.SymbolFlags.Value) {
|
||||
exportDoc.returnType = getReturnType(typeChecker, exportSymbol);
|
||||
}
|
||||
if (exportSymbol.flags & ts.SymbolFlags.TypeAlias) {
|
||||
exportDoc.typeDefinition = typeDefinition;
|
||||
}
|
||||
return exportDoc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export * from './core';
|
||||
export * from './profile';
|
||||
export * from './lifecycle_hooks';
|
||||
export * from './bootstrap';
|
||||
export * from './bootstrap';
|
||||
|
|
|
@ -18,3 +18,8 @@ export * from './src/core/directives';
|
|||
export * from './src/core/forms';
|
||||
export * from './src/core/debug';
|
||||
export * from './src/core/change_detection';
|
||||
export {Reflector, ReflectionInfo} from './src/core/reflection/reflection';
|
||||
export {
|
||||
PlatformReflectionCapabilities
|
||||
} from './src/core/reflection/platform_reflection_capabilities';
|
||||
export {SetterFn, GetterFn, MethodFn} from './src/core/reflection/types';
|
||||
|
|
|
@ -30,6 +30,7 @@ export {BaseRequestOptions, RequestOptions} from './src/http/base_request_option
|
|||
export {BaseResponseOptions, ResponseOptions} from './src/http/base_response_options';
|
||||
export {XHRBackend, XHRConnection} from './src/http/backends/xhr_backend';
|
||||
export {JSONPBackend, JSONPConnection} from './src/http/backends/jsonp_backend';
|
||||
export {BrowserJsonp} from './src/http/backends/browser_jsonp';
|
||||
export {Http, Jsonp} from './src/http/http';
|
||||
|
||||
export {Headers} from './src/http/headers';
|
||||
|
|
|
@ -7,12 +7,47 @@
|
|||
|
||||
export {Router, RootRouter} from './src/router/router';
|
||||
export {RouterOutlet} from './src/router/router_outlet';
|
||||
export {
|
||||
DynamicComponentLoader,
|
||||
ComponentRef,
|
||||
ElementRef,
|
||||
Compiler,
|
||||
AppViewManager,
|
||||
ViewRef,
|
||||
HostViewRef,
|
||||
ProtoViewRef,
|
||||
ViewContainerRef,
|
||||
TemplateRef
|
||||
} from './core';
|
||||
export {
|
||||
Renderer,
|
||||
RenderElementRef,
|
||||
RenderViewRef,
|
||||
RenderProtoViewRef,
|
||||
RenderEventDispatcher,
|
||||
RenderFragmentRef,
|
||||
RenderViewWithFragments
|
||||
} from './render';
|
||||
export {
|
||||
Binding,
|
||||
Injector,
|
||||
ResolvedBinding,
|
||||
Key,
|
||||
Dependency,
|
||||
ProtoInjector,
|
||||
DependencyProvider,
|
||||
BindingWithVisibility,
|
||||
Visibility,
|
||||
ResolvedFactory
|
||||
} from './src/core/di';
|
||||
export {RouterLink} from './src/router/router_link';
|
||||
export {RouteParams} from './src/router/instruction';
|
||||
export {RouteRegistry} from './src/router/route_registry';
|
||||
export {LocationStrategy} from './src/router/location_strategy';
|
||||
export {HashLocationStrategy} from './src/router/hash_location_strategy';
|
||||
export {PathLocationStrategy} from './src/router/path_location_strategy';
|
||||
export {PathRecognizer, PathMatch} from './src/router/path_recognizer';
|
||||
export {RouteHandler} from './src/router/route_handler';
|
||||
export {Location, APP_BASE_HREF} from './src/router/location';
|
||||
export {Pipeline} from './src/router/pipeline';
|
||||
export * from './src/router/route_config_decorator';
|
||||
|
@ -73,6 +108,8 @@ export const ROUTER_BINDINGS: any[] = CONST_EXPR([
|
|||
}))
|
||||
]);
|
||||
|
||||
export interface InjectableReference {}
|
||||
|
||||
function routerFactory(registry, pipeline, location, appRoot) {
|
||||
return new RootRouter(registry, pipeline, location, appRoot);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,13 @@ export {
|
|||
IterableDifferFactory,
|
||||
KeyValueDiffers,
|
||||
KeyValueDiffer,
|
||||
KeyValueDifferFactory
|
||||
|
||||
} from './change_detection/change_detection';
|
||||
KeyValueDifferFactory,
|
||||
Lexer,
|
||||
Parser,
|
||||
ChangeDispatcher,
|
||||
BindingTarget,
|
||||
DirectiveIndex,
|
||||
DebugContext,
|
||||
ProtoChangeDetector
|
||||
} from 'angular2/src/core/change_detection/change_detection';
|
||||
export * from 'angular2/src/core/change_detection/parser/ast';
|
||||
|
|
|
@ -21,14 +21,7 @@ import {
|
|||
assertionsEnabled
|
||||
} from 'angular2/src/core/facade/lang';
|
||||
|
||||
export {
|
||||
ASTWithSource,
|
||||
AST,
|
||||
AstTransformer,
|
||||
PropertyRead,
|
||||
LiteralArray,
|
||||
ImplicitReceiver
|
||||
} from './parser/ast';
|
||||
export * from './parser/ast';
|
||||
|
||||
export {Lexer} from './parser/lexer';
|
||||
export {Parser} from './parser/parser';
|
||||
|
|
|
@ -19,4 +19,14 @@ export {ElementRef} from './compiler/element_ref';
|
|||
export {TemplateRef} from './compiler/template_ref';
|
||||
export {ViewRef, HostViewRef, ProtoViewRef} from './compiler/view_ref';
|
||||
export {ViewContainerRef} from './compiler/view_container_ref';
|
||||
export {AppView, AppProtoView, AppProtoViewMergeMapping, AppViewContainer} from './compiler/view';
|
||||
export {ComponentRef} from './compiler/dynamic_component_loader';
|
||||
export {
|
||||
ElementInjector,
|
||||
PreBuiltObjects,
|
||||
TreeNode,
|
||||
ProtoElementInjector,
|
||||
DirectiveBinding,
|
||||
EventEmitterAccessor
|
||||
} from './compiler/element_injector';
|
||||
export {ElementBinder} from './compiler/element_binder';
|
||||
|
|
|
@ -12,3 +12,5 @@ export {LimitToPipe} from './pipes/limit_to_pipe';
|
|||
export {LowerCasePipe} from './pipes/lowercase_pipe';
|
||||
export {NumberPipe, DecimalPipe, PercentPipe, CurrencyPipe} from './pipes/number_pipe';
|
||||
export {UpperCasePipe} from './pipes/uppercase_pipe';
|
||||
export {ProtoPipes} from './pipes/pipes';
|
||||
export {PipeBinding} from './pipes/pipe_binding';
|
||||
|
|
|
@ -12,5 +12,12 @@ export {
|
|||
ViewDefinition,
|
||||
DOCUMENT,
|
||||
APP_ID,
|
||||
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE
|
||||
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
|
||||
EventManager,
|
||||
SharedStylesHost,
|
||||
DomSharedStylesHost,
|
||||
TemplateCloner,
|
||||
ViewType,
|
||||
RenderProtoViewMergeMapping,
|
||||
EventManagerPlugin
|
||||
} from './render/render';
|
||||
|
|
|
@ -10,4 +10,7 @@ export * from './dom/compiler/compiler';
|
|||
export * from './dom/dom_renderer';
|
||||
export * from './dom/dom_tokens';
|
||||
export * from './dom/template_cloner';
|
||||
export * from './dom/events/event_manager';
|
||||
export * from './dom/view/shared_styles_host';
|
||||
export * from './dom/template_cloner';
|
||||
export * from './api';
|
||||
|
|
|
@ -2,7 +2,6 @@ import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular
|
|||
import {DOM} from 'angular2/src/core/dom/dom_adapter';
|
||||
import {SelectorMatcher} from 'angular2/src/core/render/dom/compiler/selector';
|
||||
import {CssSelector} from 'angular2/src/core/render/dom/compiler/selector';
|
||||
import {ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
|
||||
|
||||
export function main() {
|
||||
describe('SelectorMatcher', () => {
|
||||
|
|
|
@ -15,7 +15,6 @@ import {
|
|||
import {DOM} from 'angular2/src/core/dom/dom_adapter';
|
||||
import {CompilePipeline} from 'angular2/src/core/render/dom/compiler/compile_pipeline';
|
||||
|
||||
import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {
|
||||
ProtoViewBuilder,
|
||||
ElementBinderBuilder
|
||||
|
|
|
@ -3,7 +3,6 @@ import {
|
|||
TextInterpolationParser
|
||||
} from 'angular2/src/core/render/dom/compiler/text_interpolation_parser';
|
||||
import {CompilePipeline} from 'angular2/src/core/render/dom/compiler/compile_pipeline';
|
||||
import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {Lexer, Parser, ASTWithSource} from 'angular2/src/core/change_detection/change_detection';
|
||||
import {IgnoreChildrenStep} from './pipeline_spec';
|
||||
import {
|
||||
|
|
|
@ -16,7 +16,6 @@ import {StyleUrlResolver} from 'angular2/src/core/render/dom/compiler/style_url_
|
|||
import {UrlResolver} from 'angular2/src/core/services/url_resolver';
|
||||
|
||||
import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async';
|
||||
import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {XHR} from 'angular2/src/core/render/xhr';
|
||||
import {MockXHR} from 'angular2/src/core/render/xhr_mock';
|
||||
import {ViewDefinition} from 'angular2/src/core/render/api';
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
SpyObject,
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
import {MapWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {DOM} from 'angular2/src/core/dom/dom_adapter';
|
||||
|
||||
import {DomTestbed, TestRootView, elRef} from './dom_testbed';
|
||||
|
|
|
@ -10,8 +10,6 @@ import {
|
|||
SpyObject
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
import {Map, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection';
|
||||
|
||||
import {RouteRecognizer} from 'angular2/src/router/route_recognizer';
|
||||
import {ComponentInstruction} from 'angular2/src/router/instruction';
|
||||
|
||||
|
|
|
@ -2,3 +2,9 @@
|
|||
export * from './test';
|
||||
export * from './src/test_lib/utils';
|
||||
export * from './src/test_lib/fake_async';
|
||||
export {ComponentRef, HostViewRef} from './src/core/compiler';
|
||||
|
||||
// This interface is referenced by TestComponents, however we can't export it directly from router
|
||||
// because router pulls in dart:html & dart:js and we import test_lib in standalone VM tests
|
||||
// so we re-create the interface here.
|
||||
export interface InjectableReference {}
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
export * from "../src/web_workers/ui/application";
|
||||
export * from '../src/core/zone';
|
||||
export * from "../src/web_workers/shared/client_message_broker";
|
||||
export * from "../src/web_workers/shared/service_message_broker";
|
||||
export * from "../src/web_workers/shared/serializer";
|
||||
export * from '../src/web_workers/shared/render_proto_view_ref_store';
|
||||
export * from '../src/web_workers/shared/render_view_with_fragments_store';
|
||||
export * from '../src/core/render/api';
|
||||
export * from '../src/core/change_detection';
|
||||
export * from '../src/core/di';
|
||||
export {Reflector, ReflectionInfo} from '../src/core/reflection/reflection';
|
||||
export {
|
||||
PlatformReflectionCapabilities
|
||||
} from '../src/core/reflection/platform_reflection_capabilities';
|
||||
export {SetterFn, GetterFn, MethodFn} from '../src/core/reflection/types';
|
||||
|
|
|
@ -14,14 +14,22 @@ export * from '../src/core/zone';
|
|||
// Do not export render in web_worker
|
||||
// export * from '../src/core/render';
|
||||
// Add special import for just render API
|
||||
export * from '../src/core/application_ref';
|
||||
export * from '../src/core/application_tokens';
|
||||
export * from '../src/core/render/api';
|
||||
export * from '../src/core/directives';
|
||||
export * from '../src/core/forms';
|
||||
export * from '../src/core/debug';
|
||||
export * from '../src/core/change_detection';
|
||||
|
||||
export * from '../profile';
|
||||
export * from '../src/web_workers/worker/application';
|
||||
export * from '../src/web_workers/shared/client_message_broker';
|
||||
export * from '../src/web_workers/shared/service_message_broker';
|
||||
export * from '../src/web_workers/shared/serializer';
|
||||
export * from '../src/web_workers/shared/render_proto_view_ref_store';
|
||||
export * from '../src/web_workers/shared/render_view_with_fragments_store';
|
||||
export {Reflector, ReflectionInfo} from '../src/core/reflection/reflection';
|
||||
export {
|
||||
PlatformReflectionCapabilities
|
||||
} from '../src/core/reflection/platform_reflection_capabilities';
|
||||
export {SetterFn, GetterFn, MethodFn} from '../src/core/reflection/types';
|
||||
|
|
|
@ -8,14 +8,8 @@ var broker = instance.app.createClientMessageBroker(ECHO_CHANNEL, false);
|
|||
document.getElementById("send_echo")
|
||||
.addEventListener("click", (e) => {
|
||||
var val = (<HTMLInputElement>document.getElementById("echo_input")).value;
|
||||
// TODO(jteplitz602): Replace default constructors with real constructors
|
||||
// once they're in the .d.ts file (#3926)
|
||||
var args = new UiArguments();
|
||||
args.method = "echo";
|
||||
var fnArg = new FnArg();
|
||||
fnArg.value = val;
|
||||
fnArg.type = PRIMITIVE;
|
||||
args.args = [fnArg];
|
||||
var fnArg = new FnArg(val, PRIMITIVE);
|
||||
var args = new UiArguments("echo", [fnArg]);
|
||||
|
||||
broker.runOnService(args, PRIMITIVE)
|
||||
.then((echo_result: string) => {
|
||||
|
|
|
@ -3,7 +3,8 @@ library angular2.transform.common.directive_metadata_reader;
|
|||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/src/generated/element.dart';
|
||||
import 'package:angular2/src/core/render/api.dart';
|
||||
import 'package:angular2/src/core/change_detection/change_detection.dart';
|
||||
import 'package:angular2/src/core/change_detection/change_detection.dart'
|
||||
show ChangeDetectionStrategy;
|
||||
|
||||
/// Reads [RenderDirectiveMetadata] from the `node`. `node` is expected to be an
|
||||
/// instance of [ClassDeclaration] (a class which may have a [Directive] or
|
||||
|
|
Loading…
Reference in New Issue