#Parameter decorators only work when experimental decorators are enabled

1 messages · Page 1 of 1 (latest)

simple basin
#

I've added the argument decorator:

  public build(@argument({ defaultPath: "../../" }) source: Directory): Container {

And started getting this error:

▼ asModule getModDef 9.5s ERROR
                                                                                                                                                                                                                           
node:internal/process/promises:394                                                                                                                                                                                         
    triggerUncaughtException(err, true /* fromPromise */);                                                                                                                                                                 
    ^                                                                                                                                                                                                                      
Error [TransformError]: Transform failed with 1 error:                                                                                                                                                                     
/src/apps/dagger/src/index.ts:8:15: ERROR: Parameter decorators only work when experimental decorators are enabled                                                                                                         
    at failureErrorWithLog (/usr/local/lib/node_modules/tsx/node_modules/esbuild/lib/main.js:1472:15)           

The tsconfig.json has experimentalDecorators set to true.

Thanks.

spiral geyser
simple basin
#

Yes

spiral geyser
#

this is how my tsconfig looks and seems to work ok here:

{
  "compilerOptions": {
    "target": "ES2022",
    "moduleResolution": "Node",
    "experimentalDecorators": true,
    "strict": true,
    "skipLibCheck": true,
    "paths": {
      "@dagger.io/dagger": ["./sdk/index.ts"],
      "@dagger.io/dagger/telemetry": ["./sdk/telemetry.ts"]
    }
  }
}
#

@simple basin . I'm running v0.18.19

#
import {
  dag,
  Container,
  Directory,
  object,
  func,
  argument,
} from "@dagger.io/dagger";

@object()
export class Tstest {
  /**
   * Returns a container that echoes whatever string argument is provided
   */
  @func()
  containerEcho(
    stringArg: string,
    @argument({ defaultPath: "." }) src: Directory,
  ): Container {
    return dag.container().from("alpine:latest").withExec(["echo", stringArg]);
  }
}

^ that's the generated example

pseudo sigil
#

cc @north oxide

simple basin
#

Ok, interesting.

I had this in my tsconfig.json:

  "include": [
    "src/**/*.ts",
    "sdk/**/*.ts"
  ],
  "exclude": []

When I took that out, it worked.

Why would having this cause this error?

#

When I run this against local version, it runs fine:

pnpm tsx --no-deprecation --tsconfig tsconfig.json src/index.ts
spiral geyser
last matrix
#

I've dug into it, coming up with the explanation in a bit: the error you encounter is happening because your tsconfig lives under .dagger/tsconfig.json (only when you dagger init in a repo with already content inside) and this matching excludes the entrypoint generated by the ts sdk inadventendly

simple basin
#

@last matrix thank you for looking into it.

I don’t use dot dagger dir.

What I actually did was init outside of the main project to see what’s needed and then ported the setup into the monorepo which uses repo tooling to setup workspaces.

So there’s tsconfig.json in the normal workspace.

#

Basically the layout of the dagger project is a typical monorepo workspace under apps/dagger

last matrix
#

I'll let Tom answer

simple basin
#

I will try to boil down my issue to bare minimum.