Skip to content

Commit 3531014

Browse files
docs: document nested type imports hazard
1 parent 5e48d0d commit 3531014

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

src/pages/docs/resources/typescript.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ The below steps will help you get up and running with TypeScript in your Greenwo
4848

4949
<!-- prettier-ignore-end -->
5050

51+
## Type Imports
52+
53+
Due to how bundlers and other [type-aware tools interpret importing types](https://github.com/ProjectEvergreen/greenwood/issues/1576#issuecomment-3795821236), when doing any `type` based imports, you will need to make sure the type is on the _outside_.
54+
55+
Example:
56+
57+
```ts
58+
// ✅ DO THIS
59+
import type { Page } from "@greenwood/cli";
60+
61+
// ❌ NOT THIS
62+
import { type Page } from "@greenwood/cli";
63+
```
64+
65+
> There is a helpful [**typescript-eslint**](https://typescript-eslint.io/rules/no-import-type-side-effects/) rule for ensuring predictable behaviors around this syntax.
66+
5167
## Types
5268

5369
### Configuration
@@ -72,8 +88,6 @@ In addition to being able to author your components, SSR pages, and API routes i
7288

7389
<!-- prettier-ignore-end -->
7490

75-
> 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.
76-
7791
See our [reference docs on Greenwood's available types](/docs/reference/appendix/#types) for more information on authoring with TypeScript.
7892

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

97111
<!-- prettier-ignore-end -->
98-
99-
## Type Imports
100-
101-
Due to a [known "issue" in NodeJS](https://github.com/nodejs/node/issues/58422), when doing `type` based imports for [Greenwood types](https://github.com/ProjectEvergreen/greenwood/issues/1576), it will be required to _**not**_ use nested type imports.
102-
103-
Example:
104-
105-
```ts
106-
// ✅ DO THIS
107-
import type { Page } from "@greenwood/cli";
108-
109-
// ❌ NOT THIS
110-
import { type Page } from "@greenwood/cli";
111-
```

0 commit comments

Comments
 (0)