小编Sun*_*ong的帖子

打字稿 TypeORM ColumnTypeUndefinedError

我尝试了 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: …

javascript typescript tsc typeorm

7
推荐指数
1
解决办法
1489
查看次数

在 VS Code 中使用 scanf 和 Code Runner 扩展

我尝试了一个非常简单的C语言代码scanf,它陷入了无限循环(或者看起来像)。代码如下:

#include <stdio.h>

int main(){
    int input = 0;
    scanf("%d", &input);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我使用了代码运行器扩展。这是以防万一的屏幕截图。 在此输入图像描述

有谁知道如何修理它?

c visual-studio-code vscode-code-runner

1
推荐指数
1
解决办法
3811
查看次数