첫 번째 간단한 ORM 기반 노드 JS 응용 프로그램을 빌드하려고합니다.모듈로 작업하는 Typescript
나는이
import * as Knex from 'knex';
import * as Bookshelf from 'bookshelf';
module Database {
class Config {
private static _knex: Knex = Knex({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'root',
password: '',
database: 'test',
charset: 'utf8'
}
});
static _bookshelf: Bookshelf = Bookshelf(Config._knex);
}
export function bookshelf() {
Config._bookshelf.plugin('registry');
Config._bookshelf.plugin(['virtuals']);
return Config._bookshelf;
}
}
같은 Database
모듈을 생성 그리고 dao/userdao.ts(18,24): error TS2304: Cannot find name 'Database'.
그것은이다이 오류와 함께 종료됩니다 DAO
클래스
/// <reference path="../models/usermodel.ts" />
/// <reference path="../network/database.ts" />
module DAO {
export class UserDAO {
create(user: Model.User): Model.User { //Model.User is imported nicely
var test = Database.bookshelf(); //what's wrong with this
return null;
}
}
}
중 하나를 사용하는 것을 시도하고있다 Typescript and Modules
에 대한 나의 첫번째 학습, 내가 뭔가 잘못하고 있는지 알려주세요.
업데이트 : 가 최대한 빨리 import statements in database.ts
를 추가, 그것은 작동하지 않습니다/이름을 찾을 수 없습니다. 내가 참조 코멘트 만 타이프에 의해 사용되는 import * as something from some