Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: More granular string typing #47

Open
bfaulk96 opened this issue Jul 16, 2021 · 2 comments
Open

Suggestion: More granular string typing #47

bfaulk96 opened this issue Jul 16, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@bfaulk96
Copy link

bfaulk96 commented Jul 16, 2021

Admittedly, I'm not sure what version of Typescript this supports, or how the types definitions are created, but with Typescript allowing template strings, would it be possible to implement something along the lines of

type ServiceProvider = 'AWS' | string;
type ServiceName = string; // Or the entire service name list
type DataTypeName = string; // Or the entire data type name list
type AWSResourceType = `${ServiceProvider}::${ServiceName}::${DataTypeName}`

(Based on the docs here)

This would further help avoid pesky typos of things like AWS::SQS:Queue and similar problems.
Just exploring ideas, feel free to close if it's not something that could be considered.

@fredericbarthelet
Copy link
Contributor

Hi @bfaulk96, thanks for the suggestion.
Typescript indeed allow string templates as valid types.
However, the typescript definitions in this repository are auto-generated from JSON-schema definitions within serverless framework. Implementing string templates would require deducting the template from JSON-schema information. Do you have an idea about the way to proceed in such workflow ?

@fredericbarthelet fredericbarthelet added the enhancement New feature or request label Oct 14, 2021
@bfaulk96
Copy link
Author

Hey @fredericbarthelet, thanks for the response!
Unfortunately, I don't really know anything about JSON-schema, so I'm not sure if it would be possible. I'll look into it and get back to you about it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants