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:
parent
8a5cf8f6bd
commit
7a4a3c850f
|
@ -68,6 +68,10 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
|
||||||
|
|
||||||
exportDoc.members = [];
|
exportDoc.members = [];
|
||||||
for(var memberName in resolvedExport.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);
|
log.silly('>>>>>> member: ' + memberName + ' from ' + exportDoc.id + ' in ' + moduleDoc.id);
|
||||||
var memberSymbol = resolvedExport.members[memberName];
|
var memberSymbol = resolvedExport.members[memberName];
|
||||||
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker);
|
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker);
|
||||||
|
@ -227,6 +231,8 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
|
||||||
}
|
}
|
||||||
if (parameter.type) {
|
if (parameter.type) {
|
||||||
paramText += ':' + getType(sourceFile, parameter.type);
|
paramText += ':' + getType(sourceFile, parameter.type);
|
||||||
|
} else {
|
||||||
|
paramText += ': any';
|
||||||
}
|
}
|
||||||
return paramText.trim();
|
return paramText.trim();
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,7 +45,9 @@ module.exports = function getExportDocType(log) {
|
||||||
var node = symbol.valueDeclaration;
|
var node = symbol.valueDeclaration;
|
||||||
while(node) {
|
while(node) {
|
||||||
if ( node.flags & 0x2000 /* const */) {
|
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;
|
node = node.parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{$ '*/' | indent(level, true) | replace(r/\n$/, "") $}{% endif -%}
|
{$ '*/' | indent(level, true) | replace(r/\n$/, "") $}{% endif -%}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
|
||||||
// Type definitions for Angular v{$ versionInfo.currentVersion.full $}
|
// Type definitions for Angular v{$ versionInfo.currentVersion.full | replace(r/\+/, "_") $}
|
||||||
// Project: http://angular.io/
|
// Project: http://angular.io/
|
||||||
// Definitions by: angular team <https://github.com/angular/>
|
// Definitions by: angular team <https://github.com/angular/>
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||||
|
@ -34,8 +34,8 @@ declare module "angular2/angular2" {
|
||||||
|
|
||||||
// See https://github.com/Microsoft/TypeScript/issues/1168
|
// See https://github.com/Microsoft/TypeScript/issues/1168
|
||||||
class BaseException /* extends Error */ {
|
class BaseException /* extends Error */ {
|
||||||
message;
|
message: string;
|
||||||
stack;
|
stack: string;
|
||||||
toString(): string;
|
toString(): string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,15 +53,15 @@ declare module "{$ module.id $}" {
|
||||||
{$ commentBlock(member, 5) $}
|
{$ commentBlock(member, 5) $}
|
||||||
{$ member.name $}
|
{$ member.name $}
|
||||||
{%- if member.parameters %}({% for param in member.parameters %}{$ param $}{% if not loop.last %}, {% endif %}{% endfor %}){%- endif %}
|
{%- 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 %}
|
{%- endfor %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{%- elif export.docType == 'enum' %} {
|
{%- elif export.docType == 'enum' %} {
|
||||||
{%- for member in export.members %}
|
{%- for member in export.members %}
|
||||||
{$ member $}{% if not loop.last %},
|
{$ member $}{% if not loop.last %},
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue