My idea was to try and create a little "hello world" Repository overview card in typescript using the following repository as an example.
https://bitbucket.org/bitbucket/bitbucket-forge-hello-world/src/main/hello-world-app/src
This is my index.tsx file.
import ForgeUI, { render, Fragment, Text, useProductContext} from "@forge/ui";
const App = () => {
const context = useProductContext();
return (
<Fragment>
<Text> "Hello world!" </Text>
<Text>Workspace ID: {JSON.stringify(context.workspaceId)}</Text>
<Text>ExtensionContext: {JSON.stringify(context.extensionContext.repository)}</Text>
</Fragment>
);
};
export const display = render(<App />);
And this is my manifest file.
modules:
bitbucket:repoCodeOverviewCard:
- key: display-metrics
title: "Test card: Repo metrics"
function: main
function:
- key: main
handler: index.display
app:
id: <id-here>
The problem i run into is in the line in the index file where I call "context.extensionContext.repository". The linter says its fine, but when trying to deploy I get the following error:
TS2339: Property 'repository' does not exist on type 'ExtensionContext'.
I tried updating my script to just use "context.extensionContext" and print that and then I see the following in my test environment:
What am I missing here? Why can I see the "repository" property, but am I not able to access it in my script?
Solved! Go to Solution.
Hi @Stijn & all,
Can you try to upgrade the @forge/ui package to the latest and try again without using the workaround?
You'll need version 1.9.9 or higher (https://www.npmjs.com/package/@forge/ui?activeTab=versions) for this to work.
We released a fix for this last week.
Cheers,
Caterina