/// <summary>
        /// Return the TypeScript type (as a string) for specified type.
        /// </summary>
        /// <param name="type">IType to query</param>
        /// <param name="inModelsModule">Pass true if generating the code for the models module, thus model types don't need a "models." prefix</param>
        /// <returns>TypeScript type string for type</returns>
        public static string TSType(this IModelType type, bool inModelsModule)
        {
            CompositeTypeTS composite  = type as CompositeTypeTS;
            SequenceType    sequence   = type as SequenceType;
            DictionaryType  dictionary = type as DictionaryType;
            PrimaryType     primary    = type as PrimaryType;
            EnumType        enumType   = type as EnumType;

            string tsType;

            if (primary != null)
            {
                tsType = primary.PrimaryTSType();
            }
            else if (enumType != null)
            {
                string enumName = enumType.DeclarationName;
                if (inModelsModule || enumName.Contains('.') || enumName == "string")
                {
                    tsType = enumName;
                }
                else
                {
                    tsType = "Models." + enumName.ToPascalCase();
                }
            }
            else if (composite != null)
            {
                // ServiceClientCredentials starts with the "msRest." prefix, so strip msRest./msRestAzure. as we import those
                // types with no module prefix needed
                var compositeName = composite.UnionTypeName;
                if (compositeName.StartsWith("msRest.") || compositeName.StartsWith("msRestAzure."))
                {
                    tsType = compositeName.Substring(compositeName.IndexOf('.') + 1);
                }
                else if (inModelsModule || compositeName.Contains('.'))
                {
                    tsType = compositeName;
                }
                else
                {
                    tsType = "Models." + compositeName;
                }
            }
            else if (sequence != null)
            {
                if (sequence.IsSequenceContainingDateKind())
                {
                    tsType = sequence.ElementType.TSType(inModelsModule) + "[]" + " | string[]";
                }
                else
                {
                    tsType = sequence.ElementType.TSType(inModelsModule) + "[]";
                }
            }
            else if (dictionary != null)
            {
                if (dictionary.IsDictionaryContainingDateKind()) //then provide a union of Date and string
                {
                    tsType = "{ [propertyName: string]: " + dictionary.ValueType.TSType(inModelsModule) + " }" + " | { [propertyName: string]: string }";
                }
                else
                {
                    tsType = "{ [propertyName: string]: " + dictionary.ValueType.TSType(inModelsModule) + " }";
                }
            }
            else
            {
                throw new NotImplementedException($"Type '{type}' not implemented");
            }

            return(tsType);
        }