Open razr001 opened 11 months ago
Also happens for me when running:
SWCRC=true node --loader @swc-node/register/esm scripts/run-local.ts
"@swc-node/register": "1.6.8"
the same here
tsoa
builds routes & swaggers specs under backend/build
folder,
then swc
should run app from backend/src
> npm run swagger && SWCRC=true dotenv -e .env.local -- node --import @swc-node/register/esm-register src/server.ts
> tsoa spec-and-routes
file:///.........backend/build/routes.ts:7
import type { Request as ExRequest, Response as ExResponse, RequestHandler, Router } from 'express';
^
SyntaxError: Unexpected token '{'
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:155:18)
at callTranslator (node:internal/modules/esm/loader:285:14)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:30)
Node.js v20.10.0
@swc-node/register
: 1.9.0
Do you have a minimal reproduction?
hey @kdy1
I've created repo https://github.com/mishelen/tsoa-swc/tree/main Please take a look
if I manually remove type
from import then it fail on next statement.
file:///.../build/routes.ts:13
const models: TsoaRoute.Models = {
^^^^^^
SyntaxError: Missing initializer in const declaration
Uhhh, but it IS initialized. Even more I don't see any errors from TS in that file in the IDE. UPDATE: whole typescript file is treated as just javascript, only after I'd removed all annotations, it started work
function fun(a?:string){ ^
SyntaxError: Unexpected token '?' at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14) at async link (node:internal/modules/esm/module_job:68:21)
Node.js v18.16.1