tsutils
Advanced tools
Comparing version 3.16.0 to 3.17.0
@@ -0,1 +1,11 @@ | ||
# 3.17.0 | ||
**Features:** | ||
* `isValidJsxIdentifier` added an optional parameter to specify the target ECMAScript version | ||
**Bugfixes:** | ||
* `isValidJsxIdentifier` now handles astral plane characters | ||
# 3.16.0 | ||
@@ -2,0 +12,0 @@ |
{ | ||
"name": "tsutils", | ||
"version": "3.16.0", | ||
"version": "3.17.0", | ||
"description": "utilities for working with typescript's AST", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -81,3 +81,3 @@ import * as ts from 'typescript'; | ||
export declare function isValidNumericLiteral(text: string, languageVersion?: ts.ScriptTarget): boolean; | ||
export declare function isValidJsxIdentifier(text: string): boolean; | ||
export declare function isValidJsxIdentifier(text: string, languageVersion?: ts.ScriptTarget): boolean; | ||
export declare function isNumericPropertyName(name: string | ts.__String): boolean; | ||
@@ -84,0 +84,0 @@ export declare function isSameLine(sourceFile: ts.SourceFile, pos1: number, pos2: number): boolean; |
@@ -550,8 +550,13 @@ "use strict"; | ||
exports.isValidNumericLiteral = isValidNumericLiteral; | ||
function isValidJsxIdentifier(text) { | ||
if (text.length === 0 || !ts.isIdentifierStart(text.charCodeAt(0), ts.ScriptTarget.ES5)) | ||
function isValidJsxIdentifier(text, languageVersion = ts.ScriptTarget.Latest) { | ||
if (text.length === 0) | ||
return false; | ||
for (let i = 1; i < text.length; ++i) | ||
if (!ts.isIdentifierPart(text.charCodeAt(i), ts.ScriptTarget.ES5) && text[i] !== '-') | ||
let ch = text.codePointAt(0); | ||
if (!ts.isIdentifierStart(ch, languageVersion)) | ||
return false; | ||
for (let i = charSize(ch); i < text.length; i += charSize(ch)) { | ||
ch = text.codePointAt(i); | ||
if (!ts.isIdentifierPart(ch, languageVersion) && ch !== 45) | ||
return false; | ||
} | ||
return true; | ||
@@ -558,0 +563,0 @@ } |
193189
3884