// Picked possibly relevant packages
"devDependencies": {
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.1",
"@types/styled-components": "^5.1.7",
"typescript": "^4.2.3",
},
"dependencies": {
"@blueprintjs/core": "^3.40.0",
"@blueprintjs/icons": "^3.25.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
},
Link to a minimal repro (fork this code sandbox): https://codesandbox.io/s/blueprintjs-ts-error-7nfml?file=/src/enabled/tsconfig.json
The sandbox is created using a Vanilla TypeScript template instead of the prepped one. I couldn't reproduce it on the template. Probably CRA-ts or other packages affect tsconfig.json (or not?) 馃
tsconfig.json on the sandbox is copied from the BluePrint Sandbox and both enabled/index.tsx and disabled/index.tsx are copied from src/Navigation.tsx.
@blueprintjs/core on a TS project without allowSyntheticDefaultImports: truetsc --noEmit or Open IDE with TS supportTypeScript compiler emits compile errors such as:
'AnchorButton' cannot be used as a JSX component.
Its instance type 'AnchorButton' is not a valid JSX element.
Type 'AnchorButton' is missing the following properties from type 'ElementClass': context, setState, forceUpdate, props, refsts(2786)
Compiles without any error.
It seems that the library uses import React from "react" and they are the root cause of the error. Replacing from that to import * as React from "react" would solve the problem.
Current workaround is to enable allowSyntheticDefaultImports on user-side.
Sorry this got introduced as a break without a major version bump... I suppose it could have waited until the upcoming 4.0 release. I am inclined to move in this direction since most React code examples are written in the Babel style which has synthetic default imports. But it's not good to force a build system change in a minor version like this. I'll revert and push a patch release.
Fixed by f515648bc0c5dd95de282b8d2332829263735bfb
Not fixed, actually
Most helpful comment
Sorry this got introduced as a break without a major version bump... I suppose it could have waited until the upcoming 4.0 release. I am inclined to move in this direction since most React code examples are written in the Babel style which has synthetic default imports. But it's not good to force a build system change in a minor version like this. I'll revert and push a patch release.