Any type info/recommendations available when using Atlaskit with TypeScript

I’m prototyping a React app in Typescript with Atlaskit components. However, it seems that there are no type declarations available. What is the recommended way of working with Atlaskit modules and Typescript?

For example, this gives an error:
import Page, { Grid } from '@atlaskit/page';

Could not find a declaration file for module ‘@atlaskit/page’. ‘…/node_modules/@atlaskit/page/dist/cjs/index.js’ implicitly has an ‘any’ type.

Hi @guw,

I am also using Typescript and Atlaskit for my add-ons. It’s unfortunate that AtlasKit does not provide types out of the box (there used to be some Typescript components, but I think they are now standardising on Flow).

Regarding your question: I have a single file declarations.d.ts in my project root folder with the following content

declare module "@atlaskit/button";
declare module "@atlaskit/page";
declare module "@atlaskit/lozenge";
...

This does not give you any type safety but at least the compile stops complaining. You basically tell the compiler that there is this module.

I did write some types for the Javascript API that I am happy to share with you.

3 Likes

I’ve been discussing this in an issue on the AtlasKit BB repo…

TL;DR - they are hoping to eventually generate Typescript declarations from Flow, there are allegedly some defs in DefinitelyTyped, but I can’t find them, and I’m still waiting on a response to that one.

I’ve taken the route of manually copying the Flow defs and hand editing into a .d.ts for just what I need - sorry they aren’t really fit for public consumption though, if the DefinitelyType stuff materialises I’ll probably contribute whatever I have to that if it fills any gaps.

1 Like

Thanks for sharing the TS library. Is there an official atlaskit or other module available to contains the typings for AP.xxx ?

Hi, I think most of the atlaskit packages provide the TS typings .e.g.:

If you know some packages are missing types or types don’t work please let us know.

Thanks,
Maciej Adamczak
Atlassian Developer

@izymesdev not to my knowledge. I assume you are looking for updated AP typings. I have uploaded some updated typings here in case you are interested. However, they are not complete and I noticed recently that many of the callback oriented APIs now also support Promises which is not covered in these types. Secretly, I am still hoping that the AtlasKit JS to TS initiative will spread further across Atlassian.
I am sure there are other vendors who have written typings for AP as well. I think CollabSoft (@remie) writes in Typescript too. Maybe they are willing to share their typings?