adonisjs / core

AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.
https://adonisjs.com
MIT License
16.89k stars 639 forks source link

ReferenceError: DateTime is not defined #4643

Closed phenomenal-hardy closed 3 months ago

phenomenal-hardy commented 3 months ago

Package version

6.12.1

Describe the bug

I get the following error, after i build and run my adonis app

the built was created using pnpm build: node ace build --ignore-ts-errors

ReferenceError: DateTime is not defined

   at anonymous app\models\auth_access_token.js:22
   17|      column({ columnName: 'tokenable_id' }),
   18|      __metadata("design:type", String)
   19|  ], AuthAccessToken.prototype, "tokanableId", void 0);
   20|  __decorate([
   21|      column.dateTime({ autoCreate: true }),
 > 22|      __metadata("design:type", DateTime)
   23|  ], AuthAccessToken.prototype, "createdAt", void 0);
   24|  __decorate([
   25|      column.dateTime({ autoCreate: true }),
   26|      __metadata("design:type", DateTime)
   27|  ], AuthAccessToken.prototype, "createdAtz", void 0);

this is the model im using

// models/auth_access_token.ts
import { DateTime } from 'luxon'
import { column } from '@adonisjs/lucid/orm'
import DefyModel from './defy_model.js'

export default class AuthAccessToken extends DefyModel {
  static table = 'public.AuthAccessToken'

  static selfAssignPrimaryKey = true

  @column({ columnName: 'tokenable_id' })
  declare tokanableId: string

  @column.dateTime({ autoCreate: true })
  declare createdAt: DateTime

  @column.dateTime({ autoCreate: true })
  declare createdAtz: DateTime

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  declare updatedAt: DateTime | null

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  declare updatedAtz: DateTime | null

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  declare lastUsedAt: DateTime | null

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  declare expiresAt: DateTime | null
}

this are my dependencies in package.json

  "devDependencies": {
    "@adonisjs/assembler": "^7.7.0",
    "@adonisjs/eslint-config": "^1.3.0",
    "@adonisjs/prettier-config": "^1.3.0",
    "@adonisjs/tsconfig": "^1.3.0",
    "@japa/api-client": "^2.0.3",
    "@japa/assert": "^3.0.0",
    "@japa/plugin-adonisjs": "^3.0.1",
    "@japa/runner": "^3.1.4",
    "@swc/core": "^1.6.7",
    "@types/luxon": "^3.4.2",
    "@types/node": "^20.14.9",
    "eslint": "^8.57.0",
    "hot-hook": "^0.2.6",
    "pino-pretty": "^11.2.1",
    "prettier": "^3.3.2",
    "ts-node": "^10.9.2",
    "typescript": "^5.5.3"
  },
  "dependencies": {
    "@adonisjs/auth": "^9.2.3",
    "@adonisjs/core": "^6.12.1",
    "@adonisjs/cors": "^2.2.1",
    "@adonisjs/lucid": "^21.1.0",
    "@adonisjs/static": "^1.1.1",
    "@google-cloud/storage": "^7.11.2",
    "@vinejs/vine": "^2.1.0",
    "luxon": "^3.4.4",
    "pg": "^8.12.0",
    "reflect-metadata": "^0.2.2",
    "uuid": "^10.0.0"
  },

any suggestions?

Reproduction repo

No response

RomainLanz commented 3 months ago

Hey @phenomenal-hardy! 👋🏻

Please downgrade your TypeScript version. Duplicate of https://github.com/orgs/adonisjs/discussions/4639#discussioncomment-9925861