📄 requiresQuoting.ts
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/type-utils/src/requiresQuoting.ts
Functions¶
requiresQuoting(name: string, target: ts.ScriptTarget): boolean
¶
Code
export function requiresQuoting(
name: string,
target: ts.ScriptTarget = ts.ScriptTarget.ESNext,
): boolean {
if (name.length === 0) {
return true;
}
if (!ts.isIdentifierStart(name.charCodeAt(0), target)) {
return true;
}
for (let i = 1; i < name.length; i += 1) {
if (!ts.isIdentifierPart(name.charCodeAt(i), target)) {
return true;
}
}
return false;
}
-
JSDoc:
-
Parameters:
name: string
target: ts.ScriptTarget
- Return Type:
boolean
- Calls:
ts.isIdentifierStart
name.charCodeAt
ts.isIdentifierPart