-
Notifications
You must be signed in to change notification settings - Fork 246
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
Better Support for Mapped Types #2901
Comments
I noticed this issue here because I get the same error message for a number of type declarations that looks like: values: Record<string, SomeInterfaceType> but not for values: Record<string, string> I converted these structures to values: RecordWrap[] where RecordWrap is type RecordWrap = { name: string; data: T; }; but I get the same JSII1003 error on these as well. values: { [key:string]: SomeInterfaceType; } also generates the error, as expected. A brief look into code seems that this might come from a call to _mapType() in assembler.ts, which in turn called from _optionalValue(), but haven't taken it any deeper than that now. |
I really would like to be able to use I can't even use export interface NextjsDistributionCdkOverrideProps
extends Pick<
cloudfront.DistributionProps,
// add to this if you want to override something
'defaultRootObject' | 'errorResponses' | 'minimumProtocolVersion' | 'priceClass' | 'webAclId'
> {} Gives the error:
|
Those types cannot be represented in non-TypeScript languages. We could imagine allowing named types to reduce the boilerplate involved in re-implementing those types ( But it is worth noting that Java, C#, and Go resort to nominal typing, where TS uses structural typing... This means the "new type" would not be related to the other one in other languages, which likely will result in API usability problems in many situations... Folks who are interested are welcome to draft an RFC to add support for these, however... as I think they can be powerful tools to reduce boilerplate. |
🚀 Feature Request
Affected Languages
TypeScript
orJavascript
Python
Java
C#
,F#
, ...)Go
General Information
Description
We would like to make an attribute of an exported Properties object Partial<>, like this:
This converts ServiceProps to a Mapped Type that JSII does not support:
error JSII1003: Only string-indexed map types are supported
This is pretty deep inside the Typescript transpilation process, so I'm not sure of the exact nature of the Mapped Type that makes it incompatible. What are the chances of a fix to JSII that supports this sort of Mapped Type?
Proposed Solution
The text was updated successfully, but these errors were encountered: