我尝试了 TypeORM,并且得到了“ColumnTypeUndefinedError:User#email 的列类型未定义且无法猜测。请确保您已在 tsconfig.json 中打开了“emitDecoratorMetadata”:true 选项。还要确保您已导入“reflect” -metadata”位于应用程序的主条目文件顶部(在导入任何实体之前)。”
该错误要求我在 tsconfig.json 中添加 "emitDecoratorMetadata": true 并导入 "reflect-metadata"。我做了这两个操作,但仍然出现此错误。谁能给我一些关于我应该为这个错误做什么的想法?
我还有另一个小错误:我的 tsconfig.json 文件有 "target": "ES6" 并且编译的 js 文件仍然有 es5 的东西。我觉得如果我的 tsconfig.json 文件在编译时什么都不做,这个小错误可能与这个 ColumnTypeUndefinedError 相关。
这是目录结构和代码。
类型.ts:
import "reflect-metadata";
import { createConnection, createConnections, Connection } from "typeorm";
import { User } from "./entity/User";
let connection;
const wrapper = async () => {
connection = await createConnection({
type: "postgres",
host: "localhost",
port: 5432,
username: "postgres",
password: "1234",
database: "test",
entities: [User],
});
await connection.connect();
};
wrapper();
console.log("abc");Run Code Online (Sandbox Code Playgroud)
实体/用户.ts: …
我尝试了一个非常简单的C语言代码scanf,它陷入了无限循环(或者看起来像)。代码如下:
#include <stdio.h>
int main(){
int input = 0;
scanf("%d", &input);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我使用了代码运行器扩展。这是以防万一的屏幕截图。 在此输入图像描述
有谁知道如何修理它?