registry icon indicating copy to clipboard operation
registry copied to clipboard

type error in typescript example

Open kumavis opened this issue 10 months ago • 3 comments

type error in typescript example

maybe this is a mismatch in pulumi id vs digitalocean id?

File: themes/default/content//registry/packages/digitalocean/api-docs/reservedipassignment

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const example = new digitalocean.ReservedIp("example", {region: "nyc3"});
const exampleDroplet = new digitalocean.Droplet("example", {
    name: "baz",
    size: digitalocean.DropletSlug.DropletS1VCPU1GB,
    image: "ubuntu-22-04-x64",
    region: digitalocean.Region.NYC3,
    ipv6: true,
    privateNetworking: true,
});
const exampleReservedIpAssignment = new digitalocean.ReservedIpAssignment("example", {
    ipAddress: example.ipAddress,
    dropletId: exampleDroplet.id, // Type 'Output<string>' is not assignable to type 'Input<number>'.
});
Type 'Output<string>' is not assignable to type 'Input<number>'.
  Type 'Output<string>' is not assignable to type 'OutputInstance<number>'.
    Types of property 'apply' are incompatible.
      Type '{ <U>(func: (t: string) => Promise<U>): Output<U>; <U>(func: (t: string) => OutputInstance<U>): Output<U>; <U>(func: (t: string) => U): Output<...>; }' is not assignable to type '{ <U>(func: (t: number) => Promise<U>): Output<U>; <U>(func: (t: number) => OutputInstance<U>): Output<U>; <U>(func: (t: number) => U): Output<...>; }'.
        Types of parameters 'func' and 'func' are incompatible.
          Types of parameters 't' and 't' are incompatible.
            Type 'string' is not assignable to type 'number'.ts(2322)
reservedIpAssignment.d.ts(91, 5): The expected type comes from property 'dropletId' which is declared here on type 'ReservedIpAssignmentArgs'

kumavis avatar Jan 27 '25 19:01 kumavis

this solved the issue, but probably better to solve inside the digitalocean provider implementation dropletId: droplet.id.apply(id => parseInt(id, 10)),

kumavis avatar Jan 27 '25 19:01 kumavis

https://github.com/pulumi/pulumi-digitalocean/issues/600 https://github.com/pulumi/pulumi/issues/17841

kumavis avatar Jan 27 '25 19:01 kumavis

Hi @kumavis. Thanks for opening an issue. It looks like the appropriate upstream issues (https://github.com/pulumi/pulumi-digitalocean/issues/600, https://github.com/pulumi/pulumi/issues/17841) are the ones you linked, so there isn't much more to do here.

If you havn't already, I would 👍 https://github.com/pulumi/pulumi/issues/17841, since that feeds back into issue prioritization.

iwahbe avatar Jan 28 '25 08:01 iwahbe