Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

What's New

David Sherret edited this page Jul 30, 2016 · 43 revisions

TsTypeInfo 5.0

  • Various improvements to imports and re-exports.
  • #169 - renameDefinitionAs bug fixes.

Breaking Changes

  • #171 - ImportDefinition.namedImports and ReExportDefinition.namedImports now has a name and alias property instead of an importName/exportName property.

Issues

TsTypeInfo 4.1

  • #132 - InterfaceDefinition / ClassDefinition - addExtends / addImplements now accepts an interface or class.
  • #168 - setType now accepts an interface or class.
  • #169 - GlobalDefinition - renameDefinitionAs(def, newName) can be used to rename a name everywhere it's used
  • #113 - The order of a definition as a child of a module or file is stored in the order property. You can change the order of a definition in a module/file by using setDefintionOrder(definition: ModuleMemberDefinition, order: number), which might be useful when writing a file.

Issues

TsTypeInfo 4.0

Breaking Changes

  • All typeExpression-like names are now just type
  • Removed TypeExpressionDefinition
  • Plural add methods are now singular and return the created definition. Example: namespaceDef.addFunctions({ ... }, { ...}, ...) is now const functionDef = namespaceDef.addFunction({ ... });

New Features

  • Lots of improvements to type
    • arrayElementType
    • intersectionTypes
    • unionTypes
    • isArray()
    • getAllDefinitions()
  • Supports generators—isGenerator
  • Allow specifying indentation for writing

Issues

TsTypeInfo 3.2

  • const enum support
  • Destructuring parameters support
  • setTypeExpression, setDefaultExpression, setReturnTypeExpression manipulation methods
  • GlobalDefinition - addDefinitionAsImportToFile method
  • FileDefinition - getModuleSpecifierToFile method

Issues

TsTypeInfo 3.1

  • Support for user defined type guards
  • Type expressions are no longer incorrectly cached

TsTypeInfo 3.0

Breaking Changes

getInfoFromFiles now returns an object with a files array property and helper methods

Previously, it would return an array:

// TSTypeInfo < 3.0
const files = TsTypeInfo.getInfoFromFiles(["V:/TestFile1.ts", "V:/TestFile2.ts"]);
const myClass = files[0].getClass("MyClass");

The problem with this is that it was kind of annoying to find a file by a file name and there wasn't a guarantee the array index would stay the same for a particular file. Now there are some helper methods for you:

// TSTypeInfo >= 3.0
const result = TsTypeInfo.getInfoFromFiles(["V:/TestFile1.ts", "V:/TestFile2.ts"]);
const myClass = result.getFile("TestFile1.ts").getClass("MyClass");

// or:
const myFileWithThreeClasses = result.getFile(f => f.classes.length === 3);

These are the helper methods currently available on this object:

  • .getFileOfDefinition(def) - Gets the file a definition is located in
  • .getFileAndNamespacesToDefinition(def) - Returns the file a definition is located in, along with an array of namespaces that the definition is nested under in order (if any).
  • .getFile(fileName | (def) => boolean) - Gets a file by it's file name (does a simple endsWith comparison) or by a search function
  • .addFiles(...) - For code generation. Allows you to add new files under the result returned.

Constructor parameters are no longer added to properties array

Previously, constructor parameters—ones with a scope—could be found on a class' properties array in addition to being stored as parameters in the constructor:

class MyClass {
    constructor(public prop: string) {
    }
}

// the above class would have the information:
myClass.constructor.parameters[0]; // { name: "prop", scope: ClassConstructorParameterScope.Public, ...etc...}
myClass.properties[0]; // { name: "prop", isConstructorParameter: true, ...etc... }

Now the isConstructorParameter property is gone and the constructor parameters are only stored in the constructor.parameters array. The reason this was done is to reduce duplication for code generation.

That being said, there is a new helper method that returns all the constructor parameters and properties. I would recommend using this when iterating a class' properties so you don't miss a constructor parameter:

// returns properties on the class and parameters in the constructor with a scope (ex. protected)
const propsAndConstructorParams = myClass.getPropertiesAndConstructorParameters();

TsTypeInfo 2.5

Added all these functions:

  • createCallSignature
  • createCallSignatureParameter
  • createClass
  • createClassConstructor
  • createClassConstructorParameter
  • createClassMethod
  • createClassMethodParameter
  • createClassProperty
  • createClassStaticMethod
  • createClassStaticMethodParameter
  • createClassStaticProperty
  • createDecorator
  • createEnum
  • createEnumMember
  • createFile -- already done
  • createFunction
  • createFunctionParameter
  • createImport
  • createIndexSignature
  • createInterface
  • createInterfaceMethod
  • createInterfaceMethodParameter
  • createInterfaceProperty
  • createNamespace
  • createReExport
  • createTypeAlias
  • createVariable

It allows for code like the following:

import {createVariable} from "ts-type-info";

const myVar = createVariable({ name: "myVar", type: "string" });

console.log(myVar.write()); // outputs: let myVar: string;

Issues

TsTypeInfo 2.4

  • TypeDefinition
    • getCallSignature
    • getDefinition
    • getProperty
    • getTypeArgument
  • TypeExpressionDefinition
    • getType
  • ImportDefinition
    • addNamedImports
    • setDefaultImport
    • getNamedImport
    • getStarImport
  • ReExportDefinition
    • addNamedExports
    • getNamedExport
    • getStarExport

Issues

TsTypeInfo 2.3

  • async keyword
  • Tuple types
  • FileNotFound displays absolute path
  • Write get and set accessors
  • Write imports and re-exports
  • Support import "./name";
  • Support star import with default import

Issues

TsTypeInfo 2.2

  • Added ability to bind writing methods in manipulation methods
  • Fix thrown errors' message property (2.2.1)
  • Fix error when calling createFile with no parameters (2.2.2)

Issues

TsTypeInfo 2.1

  • Multiple function signature support
  • Interface index signatures
  • Interface call signatures
  • Improved writing

Issues

TsTypeInfo 2.0

Breaking Changes

  • #104 - Removed parent property to reduce complexity
  • #115 - FileDefinition.defaultExport -> FileDefinition.defaultExportExpression
  • #109 - Using code-block-writer 3.0 - The writer now adds the appropriate indentation when passing it a newline
  • #108 - Throw error when someone specifies a file that doesn't exist

New Features

Manipulation Methods

There are a lot more manipulation methods now. For example: addInterfaces, addArguments, and addClasses to only name a few.

myFunction.addParameters({
    name: "myFirstParameter",
    type: "string"
}, {
    name: "mySecondParameter",
    type: "number[]"
    isRestParameter: true
});

get[Def] Methods

Most objects now have get[Def] methods. For example:

const myClass = file.getClass("MyClass");
// or
const firstClassWithThreeMethods = file.getClass(c => c.methods.length === 3);
Clone this wiki locally