Skip to content

Can not be used with react #830

@Anonyfox

Description

@Anonyfox

when installing the package @aws-cdk/cdk, there is also a JSX file exported, which contains the type definition:

declare global {
  namespace JSX {
    /**
     * Declare JSX.Element to be the lazy specification of a Construct
     */
    interface Element {
      type: ConstructConstructor
      props: any
      children: JSX.Element[]
    }
    interface ElementAttributesProperty {
      jsxProps: any
    }
    interface IntrinsicAttributes {
      id: string
    }
  }
}

this breaks all *.tsx files containing react components, like simple renderToString(<div />). I assume this is because the global namespace declaration above replaces react's types completely. This means I can not use this package in any app that uses both, aws-cdk and react. Is there any workaround to make things work again? In my tsconfig.json there is "jsx": "react" already set with no effect.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions