Skip to content

Fix linting errors in TypeScript namespace generation #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Templates/TypeScript/src/entity_types.ts.tt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ export as namespace microsoftgraph;
export type NullableOption<T> = T | null;

<#=typeScriptNamespaces.MainNamespace.ToString()#>

<#
foreach (var subNamespace in typeScriptNamespaces.SubNamespaces)
{
#>
<#=subNamespace.Value.ToString()#>
<#
#><#=subNamespace.Value.ToString()#><#
}
#>
#>
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,17 @@ public override string ToString()
/// <param name="enumType">enum</param>
private void AddEnum(OdcmEnum enumType)
{
var export = IsMainNamespace ? "export " : string.Empty;
var enumTypeName = enumType.Name.UpperCaseFirstChar();
var enumValues = enumType.GetEnumValues();
var exportTypeLength = "export type".Length + enumTypeName.Length + enumValues.Length + 3;
var exportTypeLength = (export + "type").Length + enumTypeName.Length + enumValues.Length + 3;
if (exportTypeLength < MaxLineLength)
{
sb.AppendLine($"{NamespaceIndent}export type {enumTypeName} = {enumValues};");
sb.AppendLine($"{NamespaceIndent}{export}type {enumTypeName} = {enumValues};");
}
else
{
sb.AppendLine($"{NamespaceIndent}export type {enumTypeName} =");
sb.AppendLine($"{NamespaceIndent}{export}type {enumTypeName} =");
var enums = enumValues.Split('|');
sb.Append($"{NamespaceIndent}{TabSpace}| ");
sb.Append(string.Join(Environment.NewLine + NamespaceIndent + TabSpace + "| ", enums.Select(@enum => @enum.Trim())));
Expand All @@ -141,6 +142,7 @@ private void AddEnum(OdcmEnum enumType)
/// <param name="class">entity or complex type</param>
private void AddEntityOrComplexType(OdcmClass @class)
{
var export = IsMainNamespace ? "export " : string.Empty;
var propCount = @class.Properties.Count;
var entityTypeName = @class.Name.UpperCaseFirstChar();
if (propCount == 0 && entityTypeName[0] == 'I')
Expand All @@ -159,7 +161,7 @@ private void AddEntityOrComplexType(OdcmClass @class)
var extendsStatement = @class.Base == null
? string.Empty
: $" extends {GetFullyQualifiedTypeScriptTypeName(@class.Base.GetTypeString(), @class.Base.Namespace.GetNamespaceName())}";
var exportInterfaceLine = NamespaceIndent + "export interface " + entityTypeName + extendsStatement + " {";
var exportInterfaceLine = NamespaceIndent + $"{export}interface " + entityTypeName + extendsStatement + " {";
if (propCount == 0)
{
sb.AppendLine(exportInterfaceLine + "}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,22 @@ export interface IdentitySet {
user?: NullableOption<Identity>;
}


export namespace CallRecords {
export type CallType = "unknown" | "groupCall";
export type ClientPlatform = "unknown" | "windows";
export type FailureStage = "unknown" | "callSetup";
export type MediaStreamDirection = "callerToCallee" | "calleeToCaller";
export type NetworkConnectionType = "unknown" | "wired";
export type ProductFamily = "unknown" | "teams";
export type ServiceRole = "unknown" | "customBot";
export type UserFeedbackRating = "notRated" | "bad";
export type WifiBand = "unknown" | "frequency24GHz";
export type WifiRadioType = "unknown" | "wifi80211a";
export type Modality = "audio" | "video";
export interface SingletonEntity1 extends microsoftgraph.Entity {
type CallType = "unknown" | "groupCall";
type ClientPlatform = "unknown" | "windows";
type FailureStage = "unknown" | "callSetup";
type MediaStreamDirection = "callerToCallee" | "calleeToCaller";
type NetworkConnectionType = "unknown" | "wired";
type ProductFamily = "unknown" | "teams";
type ServiceRole = "unknown" | "customBot";
type UserFeedbackRating = "notRated" | "bad";
type WifiBand = "unknown" | "frequency24GHz";
type WifiRadioType = "unknown" | "wifi80211a";
type Modality = "audio" | "video";
interface SingletonEntity1 extends microsoftgraph.Entity {
testSingleNav?: NullableOption<microsoftgraph.TestType>;
}
export interface CallRecord extends microsoftgraph.Entity {
interface CallRecord extends microsoftgraph.Entity {
version?: number;
type?: CallType;
modalities?: Modality[];
Expand All @@ -119,7 +118,7 @@ export namespace CallRecords {
sessions?: NullableOption<Session[]>;
recipients?: NullableOption<microsoftgraph.EntityType2[]>;
}
export interface Session extends microsoftgraph.Entity {
interface Session extends microsoftgraph.Entity {
modalities?: Modality[];
startDateTime?: string;
endDateTime?: string;
Expand All @@ -128,7 +127,7 @@ export namespace CallRecords {
failureInfo?: NullableOption<FailureInfo>;
segments?: NullableOption<Segment[]>;
}
export interface Segment extends microsoftgraph.Entity {
interface Segment extends microsoftgraph.Entity {
startDateTime?: string;
endDateTime?: string;
caller?: NullableOption<Endpoint>;
Expand All @@ -141,42 +140,42 @@ export namespace CallRecords {
photo?: NullableOption<Photo>;
}
// tslint:disable-next-line: no-empty-interface
export interface Option extends microsoftgraph.Entity {}
export interface Photo extends microsoftgraph.Entity {
interface Option extends microsoftgraph.Entity {}
interface Photo extends microsoftgraph.Entity {
failureInfo?: NullableOption<FailureInfo>;
option?: NullableOption<Option>;
}
export interface Endpoint {
interface Endpoint {
userAgent?: NullableOption<UserAgent>;
}
export interface UserAgent {
interface UserAgent {
headerValue?: NullableOption<string>;
applicationVersion?: NullableOption<string>;
}
export interface FailureInfo {
interface FailureInfo {
stage?: FailureStage;
reason?: NullableOption<string>;
}
export interface Media {
interface Media {
label?: NullableOption<string>;
callerNetwork?: NullableOption<NetworkInfo>;
callerDevice?: NullableOption<DeviceInfo>;
streams?: NullableOption<MediaStream[]>;
}
export interface NetworkInfo {
interface NetworkInfo {
connectionType?: NetworkConnectionType;
wifiBand?: WifiBand;
basicServiceSetIdentifier?: NullableOption<string>;
wifiRadioType?: WifiRadioType;
wifiSignalStrength?: NullableOption<number>;
bandwidthLowEventRatio?: NullableOption<number>;
}
export interface DeviceInfo {
interface DeviceInfo {
captureDeviceName?: NullableOption<string>;
sentSignalLevel?: NullableOption<number>;
speakerGlitchRate?: NullableOption<number>;
}
export interface MediaStream {
interface MediaStream {
streamId?: NullableOption<string>;
startDateTime?: NullableOption<string>;
streamDirection?: MediaStreamDirection;
Expand All @@ -185,25 +184,24 @@ export namespace CallRecords {
lowVideoProcessingCapabilityRatio?: NullableOption<number>;
averageAudioNetworkJitter?: NullableOption<string>;
}
export interface ParticipantEndpoint extends Endpoint {
interface ParticipantEndpoint extends Endpoint {
identity?: NullableOption<microsoftgraph.IdentitySet>;
feedback?: NullableOption<UserFeedback>;
}
export interface UserFeedback {
interface UserFeedback {
text?: NullableOption<string>;
rating?: UserFeedbackRating;
tokens?: NullableOption<FeedbackTokenSet>;
}
// tslint:disable-next-line: no-empty-interface
export interface FeedbackTokenSet {}
interface FeedbackTokenSet {}
// tslint:disable-next-line: no-empty-interface
export interface ServiceEndpoint extends Endpoint {}
export interface ClientUserAgent extends UserAgent {
interface ServiceEndpoint extends Endpoint {}
interface ClientUserAgent extends UserAgent {
platform?: ClientPlatform;
productFamily?: ProductFamily;
}
export interface ServiceUserAgent extends UserAgent {
interface ServiceUserAgent extends UserAgent {
role?: ServiceRole;
}
}