Package Exports
- misc-utils-of-mine-typescript
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (misc-utils-of-mine-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Utilities for dealing / defining types in TypeScript.
API
Examples:
Example with array
Check given array length
type Manager = 'John'|'Chris'|'Laura'
type Developer = 'Sebastian'|'Andrew'|'Gabriel'
type Name = Manager|Developer
interface Person<N extends Name> {
name: N
age?: number
}
// we want to check that developers in a team has exactly the number they declare at compile time
interface Team<DeveloperCount extends number> {
manager: Person<Manager>
developers: ArrayLiteral<Person<Developer>, DeveloperCount>
}
// strictly check that given developers length corresponds to team's declaration
declare function setDevelopers<DeveloperCount extends number>(team: Team<DeveloperCount>, developers: ArrayLiteral<Person<Developer>, DeveloperCount>):void
declare var team2: Team<2>
declare var team1: Team<1>
// OK:
setDevelopers(team2, [{name: 'Sebastian'}, {name: 'Andrew'}])
setDevelopers(team1, [{name: 'Sebastian'}])
// fail to compile:
setDevelopers(team2, [])
setDevelopers(team1, [{name: 'Sebastian'}, {name: 'Andrew'}])