From 20a26271423319085d321878edc5166a5449e68a Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Sun, 26 Nov 2017 22:51:44 +0100 Subject: [PATCH] CLI: Sanitize CR-only line endings (coming from jsdoc?) --- cli/lib/tsd-jsdoc/publish.js | 8 ++++---- ext/descriptor/index.d.ts | 31 ++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/cli/lib/tsd-jsdoc/publish.js b/cli/lib/tsd-jsdoc/publish.js index fb9374667..47be4e568 100644 --- a/cli/lib/tsd-jsdoc/publish.js +++ b/cli/lib/tsd-jsdoc/publish.js @@ -259,7 +259,7 @@ function getChildrenOf(parent) { // gets the literal type of an element function getTypeOf(element) { if (element.tsType) - return element.tsType; + return element.tsType.replace(/\r?\n|\r/g, "\n"); var name = "any"; var type = element.type; if (type && type.names && type.names.length) { @@ -388,7 +388,7 @@ function writeInterfaceBody(element) { writeln("{"); ++indent; if (element.tsType) - writeln(element.tsType); + writeln(element.tsType.replace(/\r?\n|\r/g, "\n")); else if (element.properties && element.properties.length) element.properties.forEach(writeProperty); --indent; @@ -529,7 +529,7 @@ function handleClass(element, parent) { ++indent; if (element.tsType) - writeln(element.tsType); + writeln(element.tsType.replace(/\r?\n|\r/g, "\n")); // constructor if (!is_interface && !element.virtual) @@ -675,7 +675,7 @@ function handleTypeDef(element, parent) { write("<", element.templates.join(", "), ">"); write(" = "); if (element.tsType) - write(element.tsType); + write(element.tsType.replace(/\r?\n|\r/g, "\n")); else { var type = getTypeOf(element); if (element.type && element.type.names.length === 1 && element.type.names[0] === "function") diff --git a/ext/descriptor/index.d.ts b/ext/descriptor/index.d.ts index cfec447e5..a93c981ab 100644 --- a/ext/descriptor/index.d.ts +++ b/ext/descriptor/index.d.ts @@ -4,9 +4,15 @@ export const FileDescriptorSet: $protobuf.Type; export const FileDescriptorProto: $protobuf.Type; -export const DescriptorProto: $protobuf.Type & { ExtensionRange: $protobuf.Type, ReservedRange: $protobuf.Type }; +export const DescriptorProto: $protobuf.Type & { + ExtensionRange: $protobuf.Type, + ReservedRange: $protobuf.Type +}; -export const FieldDescriptorProto: $protobuf.Type & { Label: $protobuf.Enum, Type: $protobuf.Enum }; +export const FieldDescriptorProto: $protobuf.Type & { + Label: $protobuf.Enum, + Type: $protobuf.Enum +}; export const OneofDescriptorProto: $protobuf.Type; @@ -18,11 +24,16 @@ export const EnumValueDescriptorProto: $protobuf.Type; export const MethodDescriptorProto: $protobuf.Type; -export const FileOptions: $protobuf.Type & { OptimizeMode: $protobuf.Enum }; +export const FileOptions: $protobuf.Type & { + OptimizeMode: $protobuf.Enum +}; export const MessageOptions: $protobuf.Type; -export const FieldOptions: $protobuf.Type & { CType: $protobuf.Enum, JSType: $protobuf.Enum }; +export const FieldOptions: $protobuf.Type & { + CType: $protobuf.Enum, + JSType: $protobuf.Enum +}; export const OneofOptions: $protobuf.Type; @@ -34,11 +45,17 @@ export const ServiceOptions: $protobuf.Type; export const MethodOptions: $protobuf.Type; -export const UninterpretedOption: $protobuf.Type & { NamePart: $protobuf.Type }; +export const UninterpretedOption: $protobuf.Type & { + NamePart: $protobuf.Type +}; -export const SourceCodeInfo: $protobuf.Type & { Location: $protobuf.Type }; +export const SourceCodeInfo: $protobuf.Type & { + Location: $protobuf.Type +}; -export const GeneratedCodeInfo: $protobuf.Type & { Annotation: $protobuf.Type }; +export const GeneratedCodeInfo: $protobuf.Type & { + Annotation: $protobuf.Type +}; export interface IFileDescriptorSet { file: IFileDescriptorProto[];