benjamn / benjamn/ast-types

TypeScript Property Signature missing definite

Open
#414 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

In the type and builder of Property Signature, there is a missing definite modifier.
I need it to generate properties like:
```typescript
class A {
b!: string
}
```
See: https://github.com/babel/babel/pull/7159
For people struggling with this, my current hack workaround:
```typescript
export function definiteTSPropertySignature(
key: namedTypes.Identifier,
typeAnnotation: namedTypes.TSTypeAnnotation
): namedTypes.TSPropertySignature {
const code = `class A {
${recast.print(key).code}!${recast.print(typeAnnotation).code}
}`;
const ast = parse(code);
return ast.program.body[0].body.body[0];
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the TypeScript Property Signature type and builder definitions, then compare their shape with the expected `b!: string` example and Babel PR 7159. Verify that the definite modifier can be represented and that generated TypeScript includes it, using the relevant existing tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.