fix(typings): Minor issues preventing angular2.d.ts from working in TS 1.4.

This removes some, but not all, of the manual work needed to patch up our
.d.ts for pushing to DefinitelyTyped. Remaining manual steps are:
- some types still missing
- declaration of decorators
- remove destructuring args

See #2686.
This commit is contained in:
Alex Eagle 2015-06-23 13:45:16 -07:00
parent 8a5cf8f6bd
commit 7a4a3c850f
3 changed files with 16 additions and 8 deletions

View File

@ -68,6 +68,10 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
exportDoc.members = [];
for(var memberName in resolvedExport.members) {
// FIXME(alexeagle): why do generic type params appear in members?
if (memberName === 'T') {
continue;
}
log.silly('>>>>>> member: ' + memberName + ' from ' + exportDoc.id + ' in ' + moduleDoc.id);
var memberSymbol = resolvedExport.members[memberName];
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker);
@ -227,6 +231,8 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
}
if (parameter.type) {
paramText += ':' + getType(sourceFile, parameter.type);
} else {
paramText += ': any';
}
return paramText.trim();
});

View File

@ -45,7 +45,9 @@ module.exports = function getExportDocType(log) {
var node = symbol.valueDeclaration;
while(node) {
if ( node.flags & 0x2000 /* const */) {
return 'const';
// DefinitelyTyped is still TS 1.4 so const is not allowed.
// https://github.com/borisyankov/DefinitelyTyped/issues/4564
return 'var'; // change to const when targetting TS 1.5
}
node = node.parent;
}

View File

@ -6,7 +6,7 @@
{$ '*/' | indent(level, true) | replace(r/\n$/, "") $}{% endif -%}
{%- endmacro -%}
// Type definitions for Angular v{$ versionInfo.currentVersion.full $}
// Type definitions for Angular v{$ versionInfo.currentVersion.full | replace(r/\+/, "_") $}
// Project: http://angular.io/
// Definitions by: angular team <https://github.com/angular/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@ -34,8 +34,8 @@ declare module "angular2/angular2" {
// See https://github.com/Microsoft/TypeScript/issues/1168
class BaseException /* extends Error */ {
message;
stack;
message: string;
stack: string;
toString(): string;
}
}
@ -53,7 +53,7 @@ declare module "{$ module.id $}" {
{$ commentBlock(member, 5) $}
{$ member.name $}
{%- if member.parameters %}({% for param in member.parameters %}{$ param $}{% if not loop.last %}, {% endif %}{% endfor %}){%- endif %}
{%- if member.returnType %}: {$ member.returnType $}{% endif -%}
{%- if member.returnType %}: {$ member.returnType $}{%- else -%}: any{% endif -%}
;
{%- endfor %}
}