Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js egg project中自动生成index.d.ts的问题 #28

Closed
tulies opened this issue Jan 5, 2019 · 2 comments
Closed

js egg project中自动生成index.d.ts的问题 #28

tulies opened this issue Jan 5, 2019 · 2 comments

Comments

@tulies
Copy link

tulies commented Jan 5, 2019

自动生成的代码是这样的

// This file is created by egg-ts-helper
// Do not modify this file!!!!!!!!!

import 'egg';
import ExportHome = require('../../../app/controller/home');

declare module 'egg' {
  interface IController {
    home: ExportHome;
  }
}

import ExportHome = require('../../../app/controller/home'); 这个感觉好怪啊。。 是不是应该用import ExportHome from '../../../app/controller/home';

@whxaxes
Copy link
Member

whxaxes commented Jan 5, 2019

因为你的项目是 js 项目,而 js 项目的模块都是 commonjs 的,对于 commonjs 的模块就是可以用 import xxx = require('xxx') 方式的,可以看一下 https://www.typescriptlang.org/docs/handbook/modules.html

如果是 ts 项目就是 esm 的方式

@whxaxes whxaxes closed this as completed Jan 5, 2019
@tulies
Copy link
Author

tulies commented Jan 5, 2019

@whxaxes 明白了。。 谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants