pulumi/tests/testdata/codegen/single-or-none-pp/nodejs/single-or-none.ts

11 lines
308 B
TypeScript

import * as pulumi from "@pulumi/pulumi";
function singleOrNone<T>(elements: pulumi.Input<T>[]): pulumi.Input<T> {
if (elements.length != 1) {
throw new Error("singleOrNone expected input list to have a single element");
}
return elements[0];
}
export const result = singleOrNone([1]);