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.

1 Like

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.

2 Likes

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

https://bitbucket.org/atlassian/atlaskit/issues/72/improve-typescript-coverage

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