我正在尝试使用Javascript来读取/写入PostgreSQL数据库.我在github上找到了这个项目.我能够获得以下示例代码以在节点中运行.
var pg = require('pg'); //native libpq bindings = `var pg = require('pg').native`
var conString = "tcp://postgres:1234@localhost/postgres";
var client = new pg.Client(conString);
client.connect();
//queries are queued and executed one after another once the connection becomes available
client.query("CREATE TEMP TABLE beatles(name varchar(10), height integer, birthday timestamptz)");
client.query("INSERT INTO beatles(name, height, birthday) values($1, $2, $3)", ['Ringo', 67, new Date(1945, 11, 2)]);
client.query("INSERT INTO beatles(name, height, birthday) values($1, $2, $3)", ['John', 68, new Date(1944, 10, 13)]);
//queries can be executed either …Run Code Online (Sandbox Code Playgroud) 假设我们在 2 个单独的文件中有 2 个简单的 TypeScript 类:
namespace A{
export abstract class ItemBase {
id:number=432;
}
}
Run Code Online (Sandbox Code Playgroud)
///<reference path="B.ts"/>
namespace A{
export class ItemType extends A.ItemBase{}
}
Run Code Online (Sandbox Code Playgroud)
///<reference path="C.ts"/>
let a:A.ItemType=new A.ItemType();
Run Code Online (Sandbox Code Playgroud)
使用扣环推动后一切正常
但是,如果我将 C.ts 文件的名称更改为 AA.ts,则会出现错误:
TypeError: Cannot read property "prototype" from undefined. (row 14, file „AA”).
如果我不实例化 Code.ts 中的 ItemType 类,问题甚至存在。
ts2gas 似乎extends在代码转译过程中没有考虑关键字并将输出的 gs 文件设置为相应的 ts 文件顺序。因此,如果我们在扩展类文件之前命名扩展类文件(按字母顺序),我们会得到一个错误。
在开发过程中,我是否必须注意 ts 文件名的正确顺序?我是否必须附加某种处理 gs 文件加载顺序的机制?当 gs 文件已经被转译时,这对我来说似乎是多余的。转译过程 (ts2gas) 应该处理以 TypeScript 方式使用的正确类扩展策略。如果 ts2gas 可以使用原型将 TypeScript …