hey team, I need some help with typescript cross-l...
# general
f
hey team, I need some help with typescript cross-lang components. I was building this sample component and here are the issues noticed 1. it works when I reference it locally, but not via git. I don't see any helpful error messages
Copy code
-> % pulumi package add <https://github.com/dmfigol/pulumi-aws-vpc-typescript>
Downloading provider: github.com_dmfigol_pulumi-aws-vpc-typescript.git
Added package "pulumi-aws-vpc-ts" to Pulumi.yaml
error: Detected that /home/dmfigol/.pulumi/plugins/resource-github.com_dmfigol_pulumi-aws-vpc-typescript.git-v0.0.0-x026726ba8803765d31f11953b7efb095be00747b/pulumi-resource-github.com_dmfigol_pulumi-aws-vpc-typescript.git exited prematurely. 
       This is *always* a bug in the provider. Please report the issue to the provider author as appropriate.
       To assist with debugging we have dumped the STDOUT and STDERR streams of the plugin:
2. sometimes/often when I change my typescript code, my stack is not picking up those changes and I get error like this:
Copy code
Diagnostics:
  pulumi:pulumi:Stack (pulumi-aws-vpc-ts-dev):
    Error: pulumi-aws-vpc-ts:index:VPC is not assignable from {vpcCidr: string}
    Cannot assign '{vpcCidr: string}' to 'pulumi-aws-vpc-ts:index:VPC':
      vpcCidrr: Missing required property 'vpcCidrr'
      Existing properties are: vpcCidrr
even though both pulumi.yaml and interface have correct attributes. it starts to work after I rerun emitting of js files from ts, but I haven't been able to fully understand what causes this problem exactly. seems like some cached value of schema? but where and how to fix it? UPD: I was able to fix it by deleting sdks/ folder completely. but is it really supposed to be this way? 3. what is the value of specifying pulumi.input in the interface? it seems everything works without it, e.g.:
Copy code
export interface VpcArgs {
    tags?: { [key: string]: string };  // versus
    tags?: { [key: string]: pulumi.Input<string> };
}
4. are there more references in how to type complex attributes, e.g. optional maps, optional nested objects, etc.? this doc page references a single string as input and it is not very helpful
a
👋 feels familiar 😅 On pt 3; without specifying
pulumi.Input
, you'll break when users pass an Output of another resource in? It will however work when you pass it known values from your application. You probably want the component from all languages, and joining pulumi dependency graphs, so that means Input. At least in Python, I found setting up some yaml test programs to be quite helpful, because you can run really far in the wrong direction before realizing you've forgotten you should be working with Outputs. Maybe that can help you hunt down 1 and 2. On pt 4; amen. Python is mystical at the moment and I'm running back to TypedDicts 🏃 Hope that helps
f
@able-dusk-25606 thanks, good point about passing output from something else as input. unlikely use-case for my component, but still possible. I wasn't able to solve these problems so I will probably create an issue wrt python - my experience improved when I transformed pulumi typeddict args to pydantic class. it is annoying to define arguments almost twice, but in my opinion it was worth it in python https://github.com/dmfigol/pulumi-aws-vpc-python/blob/main/src/pulumi_aws_vpc/vpc.py#L88 that said I am more and more convinced that TS experience with pulumi is better than python
a
🤔 yeah I've been watching your example 🍿 thanks for sharing that! But I couldn't get pydantic models to be OK with Inputs when calling from other languages and with Outputs from other resources. Validation breaks down because the values are not yet known. So I went back to TypedDicts only and instantiated a dataclass with a broader purpose and no Input[]s inside of an apply. All the while thinking why the hell am I doing this in Python. Glad to hear the experience is better in Typescript!
f
hm... yeah you are right, it makes sense with regards to non-strings breaking pydantic. yeah TS feels much better for pulumi, even though I have 10+ yoe in python and 0 in TS.
@modern-spring-15520 could you help me get some attention so at least items 1 and 2? I don't know if it is skill issue or a bug
m
Hi @famous-ambulance-44173 I asked internally and will see if I get a response. For 1, have your tried tagging the repo? When I use components I do that.
Copy code
git tag v0.1.0 && git push --tags
pulumi package add <https://github.com/dmfigol/pulumi-aws-vpc-typescript@v0.1.0>
f
@modern-spring-15520 not yet. I tag when it is ready to release. for python component tagging was not needed for sure.
m
I shared this thread with the components team. Hopefully someone will have a time to take a look. It does seem like 1 is related to version being a git commit vs a tag somehow. But yeah if it works untagged with python, seems like it should ts as well. I didn't see any related issues here: https://github.com/pulumi/pulumi/issues?q=state%3Aopen%20label%3A%22area%2Fcomponent-packages%22
f
thank you, Adam!