Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/pages/docs/resources/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ In addition to being able to author your components, SSR pages, and API routes i

<!-- prettier-ignore-end -->

> We recommend putting the `type` on the outside of the braces to avoid [inadvertent bundling](https://github.com/ProjectEvergreen/greenwood/issues/1576) of the package your importing from.

See our [reference docs on Greenwood's available types](/docs/reference/appendix/#types) for more information on authoring with TypeScript.

### Import Attributes
Expand All @@ -95,3 +93,17 @@ Currently TypeScript only supports types for standard [JSON Import Attributes](h
</app-ctc-block>

<!-- prettier-ignore-end -->

## Type Imports

Due to how bundlers and other [type-aware tools handle `type` based imports](https://github.com/ProjectEvergreen/greenwood/issues/1576#issuecomment-3795821236), you will need to make sure the `type` qualifier is at the _**top level**_ of the import statement so as to prevent side-effectful import statements from being left behind and included in your bundles.

```ts
// ✅ DO THIS
import type { Page } from "@greenwood/cli";

// ❌ NOT THIS
import { type Page } from "@greenwood/cli";
```

> There is a helpful [**typescript-eslint** rule](https://typescript-eslint.io/rules/no-import-type-side-effects/) for ensuring predictable behaviors around this syntax.