Skip to content

Commit 20a2627

Browse files
committed
CLI: Sanitize CR-only line endings (coming from jsdoc?)
1 parent c482a5b commit 20a2627

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

cli/lib/tsd-jsdoc/publish.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function getChildrenOf(parent) {
259259
// gets the literal type of an element
260260
function getTypeOf(element) {
261261
if (element.tsType)
262-
return element.tsType;
262+
return element.tsType.replace(/\r?\n|\r/g, "\n");
263263
var name = "any";
264264
var type = element.type;
265265
if (type && type.names && type.names.length) {
@@ -388,7 +388,7 @@ function writeInterfaceBody(element) {
388388
writeln("{");
389389
++indent;
390390
if (element.tsType)
391-
writeln(element.tsType);
391+
writeln(element.tsType.replace(/\r?\n|\r/g, "\n"));
392392
else if (element.properties && element.properties.length)
393393
element.properties.forEach(writeProperty);
394394
--indent;
@@ -529,7 +529,7 @@ function handleClass(element, parent) {
529529
++indent;
530530

531531
if (element.tsType)
532-
writeln(element.tsType);
532+
writeln(element.tsType.replace(/\r?\n|\r/g, "\n"));
533533

534534
// constructor
535535
if (!is_interface && !element.virtual)
@@ -675,7 +675,7 @@ function handleTypeDef(element, parent) {
675675
write("<", element.templates.join(", "), ">");
676676
write(" = ");
677677
if (element.tsType)
678-
write(element.tsType);
678+
write(element.tsType.replace(/\r?\n|\r/g, "\n"));
679679
else {
680680
var type = getTypeOf(element);
681681
if (element.type && element.type.names.length === 1 && element.type.names[0] === "function")

ext/descriptor/index.d.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ export const FileDescriptorSet: $protobuf.Type;
44

55
export const FileDescriptorProto: $protobuf.Type;
66

7-
export const DescriptorProto: $protobuf.Type & { ExtensionRange: $protobuf.Type, ReservedRange: $protobuf.Type};
7+
export const DescriptorProto: $protobuf.Type & {
8+
ExtensionRange: $protobuf.Type,
9+
ReservedRange: $protobuf.Type
10+
};
811

9-
export const FieldDescriptorProto: $protobuf.Type & { Label: $protobuf.Enum, Type: $protobuf.Enum};
12+
export const FieldDescriptorProto: $protobuf.Type & {
13+
Label: $protobuf.Enum,
14+
Type: $protobuf.Enum
15+
};
1016

1117
export const OneofDescriptorProto: $protobuf.Type;
1218

@@ -18,11 +24,16 @@ export const EnumValueDescriptorProto: $protobuf.Type;
1824

1925
export const MethodDescriptorProto: $protobuf.Type;
2026

21-
export const FileOptions: $protobuf.Type & { OptimizeMode: $protobuf.Enum};
27+
export const FileOptions: $protobuf.Type & {
28+
OptimizeMode: $protobuf.Enum
29+
};
2230

2331
export const MessageOptions: $protobuf.Type;
2432

25-
export const FieldOptions: $protobuf.Type & { CType: $protobuf.Enum, JSType: $protobuf.Enum};
33+
export const FieldOptions: $protobuf.Type & {
34+
CType: $protobuf.Enum,
35+
JSType: $protobuf.Enum
36+
};
2637

2738
export const OneofOptions: $protobuf.Type;
2839

@@ -34,11 +45,17 @@ export const ServiceOptions: $protobuf.Type;
3445

3546
export const MethodOptions: $protobuf.Type;
3647

37-
export const UninterpretedOption: $protobuf.Type & { NamePart: $protobuf.Type};
48+
export const UninterpretedOption: $protobuf.Type & {
49+
NamePart: $protobuf.Type
50+
};
3851

39-
export const SourceCodeInfo: $protobuf.Type & { Location: $protobuf.Type};
52+
export const SourceCodeInfo: $protobuf.Type & {
53+
Location: $protobuf.Type
54+
};
4055

41-
export const GeneratedCodeInfo: $protobuf.Type & { Annotation: $protobuf.Type};
56+
export const GeneratedCodeInfo: $protobuf.Type & {
57+
Annotation: $protobuf.Type
58+
};
4259

4360
export interface IFileDescriptorSet {
4461
file: IFileDescriptorProto[];

0 commit comments

Comments
 (0)