I’m using one of the Admin Page Console Apps for JIra as well as Forge UI Kit 2. This works out of the box, however I have run into a runtime issue after adding support for Typescript.
I’ve made the following changes to the templated code:
1. renamed the frontend/src/index.jsx file to index.tsx
2.added the following tsconfig.json file
{
"compileOnSave": true,
"compilerOptions": {
"outDir": "./dist/",
"module": "commonjs",
"target": "es2017",
"sourceMap": true,
"moduleResolution": "node",
"esModuleInterop": true,
"lib": ["dom", "es2017"],
"types": ["node", "react"],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "react",
"jsxFactory": "ForgeUI.createElement",
"jsxFragmentFactory": "Fragment",
"typeRoots": [
"./node_modules/@types"
],
"baseUrl": "."
},
"include": [ "./**/*" ],
"exclude": [ "node_modules", "build", "dist" ]
}
- Modified the manifest.yml file:
app:
id:
modules:
jira:adminPage:
- key: stpa-app-hello-world-admin-page
resource: main
resolver:
function: resolver
render: native
title: stpa-app
function:
- key: resolver
handler: index.handler
resources:
- key: main
path: src/frontend/index.tsx
- key: static-icons
path: static/icons
- key: static-images
path: static/images
permissions:
external:
images:
- stpa.com
scopes: []
Everything compiles with: tsc -d -p .
forge deploy and forge install complete ok
However at runtime, I’m seeing the following error
Uncaught TypeError: i.default.createElement is not a function
at 3181 (index.tsx:348:5)
at a (bootstrap:24:23)
at startup:6:27
at startup:6:47
The index.tsx code is as follows
import React, { useEffect, useState } from 'react';
import ForgeReconciler, { Text } from '@forge/react';
import ForgeUI from '@forge/react';
import Fragment from '@forge/react';
import { invoke } from '@forge/bridge';
const App = () => {
const [data, setData] = useState(null);
useEffect(() => {
invoke('getText', { example: 'my-invoke-variable' }).then(setData);
}, []);
return (
<>
<Text>Hello world!</Text>
<Text>{data ? data : 'Loading...'}</Text>
</>
);
};
ForgeReconciler.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
Any help would be much appreciated.
Thanks!