From f335cd343d6b4f2a97f172aef1dee8ccda62876e Mon Sep 17 00:00:00 2001 From: Parkreiner Date: Wed, 26 Jun 2024 16:00:40 +0000 Subject: [PATCH] fix: update type definitions for helpers --- test.ts | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/test.ts b/test.ts index 37e0805..faac253 100644 --- a/test.ts +++ b/test.ts @@ -76,27 +76,22 @@ export const execContainer = async ( }; }; +type TerraformStateResource = { + type: string; + name: string; + provider: string; + instances: [{ attributes: Record }]; +}; + export interface TerraformState { outputs: { [key: string]: { type: string; value: any; }; - } - resources: [ - { - type: string; - name: string; - provider: string; - instances: [ - { - attributes: { - [key: string]: any; - }; - }, - ]; - }, - ]; + }; + + resources: [TerraformStateResource, ...TerraformStateResource[]]; } export interface CoderScriptAttributes { @@ -168,9 +163,11 @@ export const testRequiredVariables = ( // runTerraformApply runs terraform apply in the given directory // with the given variables. It is fine to run in parallel with // other instances of this function, as it uses a random state file. -export const runTerraformApply = async ( +export const runTerraformApply = async < + TVars extends Readonly>, +>( dir: string, - vars: Record, + vars: TVars, ): Promise => { const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`; const env = {}; @@ -221,5 +218,5 @@ export const createJSONResponse = (obj: object, statusCode = 200): Response => { "Content-Type": "application/json", }, status: statusCode, - }) -} \ No newline at end of file + }); +};