德诺棉 'must have type'

Deno cotton 'must have type'

我正在学习 Deno 和 Angular 的课程,但我被卡住了。我什至下载了创建课程的人提供的最终代码并得到了相同类型的错误。

当我尝试 运行 这个命令时:deno 运行 --allow-net --unstable app.ts

我不断收到此错误消息:

Check file:///?:/????/deno-admin-main/app.ts error: Uncaught Error: Column 'role_id' must have a type! throw new Error(Column '${propertyKey}' must have a type!);
^
at https://deno.land/x/cotton@v0.7.5/src/model.ts:76:13 at DecorateProperty (https://deno.land/x/cotton@v0.7.5/src/utils>/reflect.ts:1431:27) at Reflect.decorate (https://deno.land/x/cotton@v0.7.5/src/utils/reflect.ts:858:16) at __decorate (file:///?:/????/deno-admin-main/src/models/role-permission.ts:3:92) at file:///?:/????/deno-admin-main/src/models/role-permission.ts:9:5

// 角色权限

import {Model, Primary, Column} from "https://deno.land/x/cotton@v0.7.5/mod.ts";

@Model('role_permissions')
export class RolePermission {
    @Primary()
    id!: number;

    @Column()
    role_id!: number;

    @Column()
    permission_id!: number;
}

根据他们的 docs 使用此 cotton 功能需要在 运行 程序时包含自定义 tsconfig.json

Keep in mind that this feature requires a custom TypeScript configuration to tell Deno that we want to use TypeScript decorators (opens new window), which is currently still an experimental feature.

// tsconfig.json

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}
deno run --unstable --config ./tsconfig.json app.ts

问题是打字错误。我没有将“app.ts”添加到文件 scripts.json:

{
  "$schema": "https://deno.land/x/denon@2.4.7/schema.json",
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "run my app.ts file",
      "allow": [ 
        "net"
      ] ,
      "tsconfig": "tsconfig.json"  
    }
  },
  "watcher": {
    "match": [
      "app.ts",
      "src/**/*.ts"
    ]
  }
}