Releases: eggjs/egg-ts-helper
Releases · eggjs/egg-ts-helper
1.16.1
1.16.0
- chore: update comment
- feat: add prefix to interface
- refactor: add esModuleInterop option
- feat: add new generator
function
andobject
- refactor: refactor build-in generators
// ./tshelper.js
module.exports = {
watchDirs: {
model: {
path: 'app/model', // dir path
generator: 'class', // generator name
interface: 'IModel', // interface name
declareTo: 'Context.model', // declare to this interface
}
}
}
generator
set to class
.
interface IModel {
Station: Station;
}
generator
set to function
.
interface IModel {
Station: ReturnType<typeof Station>;
}
generator
set to object
.
interface IModel {
Station: typeof Station;
}
1.15.0
- feat: add
declareTo
option - chore: upgrade typescript to 3.0
// ./tshelper.js
module.exports = {
watchDirs: {
model: {
path: 'app/model', // dir path
generator: 'class', // generator name
interface: 'IModel', // interface name
declareTo: 'Context.model', // declare to this interface
}
}
}
declareTo
set to Context.model
import Station from '../../../app/model/station';
declare module 'egg' {
interface Context {
model: IModel;
}
interface IModel {
Station: Station;
}
}
declareTo
set to Application.model.subModel
import Station from '../../../app/model/station';
declare module 'egg' {
interface Application {
model: {
subModel: IModel;
}
}
interface IModel {
Station: Station;
}
}
1.7.0
Support auto create d.ts for middleware
- fix: lint fix
- feat: support auto created d.ts for middleware
The middleware
// app/middlware/uuid.ts
export default function() {
return async (context, next) => {
await next();
};
}
The d.ts created by ets
// typings/middleware/index.d.ts
import Uuid from '../../../app/middleware/uuid';
declare module 'larva' {
interface IMiddleware {
uuid: ReturnType<typeof Uuid>;
}
}