question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile-time resource/data type name for TypeScript bindings

See original GitHub issue

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave “+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Right now, generated TypeScript for the various available providers (@cdktf/provider-aws, @cdktf/provider-github, etc.) offer classes where the Terraform type is available as a static readonly string:

// .d.ts
export declare class LambdaFunction extends cdktf.TerraformResource {
  static readonly tfResourceType: string;
  // ...
}
// .ts
class LambdaFunction extends cdktf.TerraformResource {
  constructor(scope, id, config) {
    super(scope, id, {
      terraformResourceType: 'aws_lambda_function'
      // ...
    });
  }
}

While already convenient, this prevents doing some compile-time designs as the value is a simple string from TypeScript’s point of view.

As the value is known ahead of time and does not change, it would be nice having it directly available in the declaration:

// .d.ts
export declare class LambdaFunction extends cdktf.TerraformResource {
  static readonly tfResourceType: 'aws_lambda_function';
  // ...
}

References

n/a

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

0reactions
github-actions[bot]commented, Nov 28, 2022

I’m going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you’ve found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Obtain the name of a Generic on compile time - Stack Overflow
TL;DR: no, there's no good way to do this. In your example, the type named MyClass is the interface given to instances of...
Read more >
Documentation - SolidJS · Reactive Javascript Library
A declarative, efficient and flexible JavaScript library for building user interfaces.
Read more >
Safari Technology Preview Release Notes - Apple Developer
Preview the new type of phishing-resistant credential that makes signing in to websites safer and easier. Available through Safari's WebAuthn platform ...
Read more >
Vehlmell - Bitsavers.org
ACllON: In Typescript, enter the command. 'echo foobar /dev/console. RESULT: The word "foobar" followed by a timestamp should appear in the Em>rLog, ...
Read more >
@profusion/json-schema-to-typescript-definitions - npm
This is a TypeScript definitions that can automatically generate TypeScript types given JSON Schema definitions without the need of any code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found