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 Apr 15, 2017 · 43 revisions

TsTypeInfo 7.0

  • #218 - Method and function signatures in an ambient context will have a generated implementation signature - Breaking change
  • #151 - TypeDefinition manipulation improvements.
  • #228 - Update getInfoFromString to not use a temporary file.
  • #227 - Use TS 2.2 compiler.
  • #212 - Add setUserDefinedTypeGuard.

Bug fixes

There are a lot of bug fixes in this release that are unfortunately undocumented because I originally had the idea to split up code generation into a separate library, fixed a bunch of issue, then decided not to do that and merged it back here.

  • #235 - Fix interface documentation generation.
  • #230 - userDefinedTypeGuard should exist on CallSignatureDefinition.
  • #221 - Fix some writers incorrectly writing declare keyword before export.
  • #215 - Fix ClassConstructorStructure to extend OverloadSignaturedStructure.
  • #216 - Fix indexSignatures missing from InterfaceStructure.
  • #220 - Fix decorators to always use fully qualified name.

Issues

TsTypeInfo 6.2

  • #206 - Add ability to use tsconfig.json for compiler options.
  • #210 - Allow passing in custom compiler host.
  • #207 - Support baseUrl and paths.
  • #180 - Documentation comment support.

Bug fixes

  • #203 - Fix decorator writing.
  • #221 - v6.2.2 - Fix: Multiline/multiple variable declarations yield only first declaration. (Thanks to @michaelneu for the fix)

Issues

TsTypeInfo 6.1

  • #185 - Add flag to include typescript compiler nodes (See readme).
  • #196 - Support overloads for constructors.

Bug fixes

  • #198 - Get methods should be Def | null for strict null checks.
  • #199 - Destructuring parameters doesn't work if no explicit type is provided.
  • #200 - Destructuring parameters as readonly doesn't work.

Issues

TsTypeInfo 6.0

  • TypeScript 2.0 support
    • #160 - Readonly modifier
    • #173 - Abstract properties
    • #174 - Constructor visibility
    • #175 - this type for functions
    • #178 - Update compiler options index signature for TS 2.0.
  • #172 - Definition file supports strict null checks

Breaking Changes

  • #176 - Improved get and set accessor support. There is now a kind property which can be used to tell if a property has a get accessor, set accessor, or both. IMPORTANT: The isReadonly now indicates the readonly modifier.
  • #183 - TypeDefinition - Fix text and add node property.
  • #189 - Remove user-defined type guards found on every definition.

Bug Fixes

  • #182 - Fix enum definitions to show up in definitions array on a type when the type is an enum.

Issues

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