dsherret / dsherret/ts-morph

Support using native `TypeNode` to set type of a `Structure`

Open
#819 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**

Currently, the `type` property of a `Structure` only support `string | WriterFunction`. If I want to set the value with a native `TypeNode`, I had to wrap it using `printNode()` like the example below.

```typescript
const project = new Project();

const common = project.createSourceFile("common.ts");

common.addTypeAlias(
{
name: "integer",
type: printNode(ts.createIntersectionTypeNode(...)),
});
```

**Describe the solution you'd like**

I hope I can use it without any wrapper.

```typescript
const project = new Project();

const common = project.createSourceFile("common.ts");

common.addTypeAlias(
{
name: "integer",
type: ts.createIntersectionTypeNode(...),
});
```

**Describe alternatives you've considered**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.