Giter Club home page Giter Club logo

Comments (6)

aaron61591 avatar aaron61591 commented on August 14, 2024

注释掉 typings/config/index.d.ts 中自动生成的部分,就能通过类型检查

declare module '@ali/my-egg' {
  interface Application {
    config: NewEggAppConfig;
  }

  interface Controller {
    config: NewEggAppConfig;
  }

  interface Service {
    config: NewEggAppConfig;
  }
}

from egg-ts-helper.

whxaxes avatar whxaxes commented on August 14, 2024

我看一下

from egg-ts-helper.

whxaxes avatar whxaxes commented on August 14, 2024

能否看一下你的 @ali/my-egg 的声明是怎么写的?

from egg-ts-helper.

whxaxes avatar whxaxes commented on August 14, 2024

生成的声明,使用 interface ,目的是跟 egg 中声明的 Service 那个 class 做声明合并。这个错误看上去是你的 @ali/my-egg 中的声明没有继承 egg 的。所以你 import 进来的 Service 就是个 interface 而不是个 class

所以你的 @ali/my-egg 里的声明需要这么写

import * as Egg from 'egg';
export = Egg;

from egg-ts-helper.

aaron61591 avatar aaron61591 commented on August 14, 2024

我的声明是这样写的,一开始也通过 export = Egg 实现,但是会导致无法 export 其他工具和通用对象

declare module 'egg' {
  interface IService {
    common: Common; // 一些通用的服务
  }
}
export * from 'egg';

export utils = {};
export someDTO = {};

from egg-ts-helper.

whxaxes avatar whxaxes commented on August 14, 2024

@aaron61591 可以啊,钉钉上找我聊一下?钉钉搜 吖猩

from egg-ts-helper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.