feat(typings): allow declaration of reference paths

Without this feature, each bundle would have to create its own typings
template to include references to dependent typings. Now, the references
can be declared in JS, along with other meta information about the 
bundle typings.


Closes #3540
This commit is contained in:
Jeff Cross 2015-08-07 16:42:36 -07:00
parent 1562bc91ba
commit 1f692ae263
4 changed files with 15 additions and 9 deletions

View File

@ -46,12 +46,15 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
createTypeDefinitionFile.typeDefinitions = [ createTypeDefinitionFile.typeDefinitions = [
{ {
id: 'angular2/angular2', id: 'angular2/angular2',
references: ['../es6-promise/es6-promise.d.ts', '../rx/rx.d.ts'],
modules: { modules: {
'angular2/angular2': 'angular2/angular2', 'angular2/angular2': 'angular2/angular2',
} }
}, },
{ {
id: 'angular2/router', id: 'angular2/router',
//Right now the typings live in the same directory, but eventually will not. See #3458
references: ['../angular2/angular2.d.ts'],
modules: { modules: {
'angular2/router': 'angular2/router' 'angular2/router': 'angular2/router'
} }

View File

@ -33,7 +33,7 @@ module.exports = function createTypeDefinitionFile(log) {
// A type definition may include a number of top level modules // A type definition may include a number of top level modules
// And those modules could be aliased (such as 'angular2/angular2.api' -> 'angular2/angular2') // And those modules could be aliased (such as 'angular2/angular2.api' -> 'angular2/angular2')
moduleDocs: _.transform(def.modules, function(moduleDocs, id, alias) { moduleDocs: _.transform(def.modules, function(moduleDocs, id, alias) {
moduleDocs[id] = { id: alias, doc: null }; moduleDocs[id] = { id: alias, doc: null, references: def.references };
}) })
}; };
}); });

View File

@ -1,10 +1,5 @@
{% extends '../type-definition.template.html' %} {% extends '../type-definition.template.html' %}
{% block staticDeclarations %} {% block staticDeclarations %}
// Angular depends transitively on these libraries.
// If you don't have them installed you can run
// $ tsd query es6-promise rx rx-lite --action install --save
///<reference path="../es6-promise/es6-promise.d.ts"/>
///<reference path="../rx/rx.d.ts"/>
interface List<T> extends Array<T> {} interface List<T> extends Array<T> {}
interface Map<K,V> {} interface Map<K,V> {}

View File

@ -28,6 +28,14 @@
// Please do not create manual edits or send pull requests // Please do not create manual edits or send pull requests
// modifying this file. // modifying this file.
// *********************************************************** // ***********************************************************
{% for alias, module in doc.moduleDocs %}
{%- if module.references.length %}
// Angular depends transitively on these libraries.
// If you don't have them installed you can install them using TSD
// https://github.com/DefinitelyTyped/tsd
{%- endif %}
{% for reference in module.references %}
///<reference path="{$ reference $}"/>{% endfor %}{% endfor %}
{% block staticDeclarations %}{% endblock %} {% block staticDeclarations %}{% endblock %}
{% for alias, module in doc.moduleDocs %} {% for alias, module in doc.moduleDocs %}
{$ commentBlock(module.doc, 1) $} {$ commentBlock(module.doc, 1) $}