MCPcopy Create free account
hub / github.com/coder/guts / propertySignature

Function propertySignature

typescript-engine/src/index.ts:35–58  ·  view source on GitHub ↗
(
  modifiers: readonly modifierKeys[] | readonly ts.Modifier[] | undefined,
  name: string,
  question: boolean,
  type: ts.TypeNode
)

Source from the content-addressed store, hash-verified

33}
34
35export function propertySignature(
36 modifiers: readonly modifierKeys[] | readonly ts.Modifier[] | undefined,
37 name: string,
38 question: boolean,
39 type: ts.TypeNode
40): ts.PropertySignature {
41
42 var id: Identifier | StringLiteral = identifier(name);
43
44 // Property names can be quoted if they are not valid identifiers.
45 // This is things like hyphens, numbers first, etc.
46 // TODO: If this regex exists in the typescript compiler, use that instead.
47 if(!(/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))) {
48 id = ts.factory.createStringLiteral(name);
49 }
50
51
52 return ts.factory.createPropertySignature(
53 modifiers?.map((m) => modifier(m)),
54 id,
55 question ? questionToken() : undefined,
56 type
57 );
58}
59
60export function questionToken(): ts.QuestionToken {
61 return ts.factory.createToken(ts.SyntaxKind.QuestionToken);

Callers 1

PropertySignatureMethod · 0.85

Calls 3

identifierFunction · 0.85
modifierFunction · 0.85
questionTokenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…