@@ -42,7 +42,7 @@ const _surrogateCharMap: { [code: number]: CharCategoryMap } = {};
42
42
// We do lazy initialization of this map because it's rarely used.
43
43
let _identifierCharMapInitialized = false ;
44
44
45
- export function isIdentifierStartChar ( char : number , nextChar ?: number ) {
45
+ export function isIdentifierStartChar ( char : number , nextChar ?: number ) : boolean {
46
46
if ( char < _identifierCharFastTableSize ) {
47
47
return _identifierCharFastTable [ char ] === CharCategory . StartIdentifierChar ;
48
48
}
@@ -63,7 +63,7 @@ export function isIdentifierStartChar(char: number, nextChar?: number) {
63
63
return charCategory === CharCategory . StartIdentifierChar ;
64
64
}
65
65
66
- export function isIdentifierChar ( char : number , nextChar ?: number ) {
66
+ export function isIdentifierChar ( char : number , nextChar ?: number ) : boolean {
67
67
if ( char < _identifierCharFastTableSize ) {
68
68
return (
69
69
_identifierCharFastTable [ char ] === CharCategory . StartIdentifierChar ||
@@ -77,17 +77,17 @@ export function isIdentifierChar(char: number, nextChar?: number) {
77
77
_identifierCharMapInitialized = true ;
78
78
}
79
79
80
+ let charCategory : CharCategory ;
80
81
if ( nextChar !== undefined ) {
81
- return _lookUpSurrogate ( char , nextChar ) ;
82
+ charCategory = _lookUpSurrogate ( char , nextChar ) ;
83
+ } else {
84
+ charCategory = _identifierCharMap [ char ] ;
82
85
}
83
86
84
- return (
85
- _identifierCharMap [ char ] === CharCategory . StartIdentifierChar ||
86
- _identifierCharMap [ char ] === CharCategory . IdentifierChar
87
- ) ;
87
+ return charCategory === CharCategory . StartIdentifierChar || charCategory === CharCategory . IdentifierChar ;
88
88
}
89
89
90
- export function isSurrogateChar ( char : number ) {
90
+ export function isSurrogateChar ( char : number ) : boolean {
91
91
if ( char < _identifierCharFastTableSize ) {
92
92
return false ;
93
93
}
@@ -129,7 +129,7 @@ export function isBinary(ch: number): boolean {
129
129
return ch === Char . _0 || ch === Char . _1 || ch === Char . Underscore ;
130
130
}
131
131
132
- function _lookUpSurrogate ( char : number , nextChar : number ) {
132
+ function _lookUpSurrogate ( char : number , nextChar : number ) : CharCategory {
133
133
if ( _identifierCharMap [ char ] !== CharCategory . SurrogateChar ) {
134
134
return CharCategory . NotIdentifierChar ;
135
135
}
@@ -197,7 +197,7 @@ function _buildIdentifierLookupTableFromUnicodeRangeTable(
197
197
fastTableOnly : boolean ,
198
198
fastTable : CharCategoryMap ,
199
199
fullTable : CharCategoryMap
200
- ) {
200
+ ) : void {
201
201
for ( let entryIndex = 0 ; entryIndex < table . length ; entryIndex ++ ) {
202
202
const entry = table [ entryIndex ] ;
203
203
let rangeStart : number ;
@@ -227,7 +227,7 @@ function _buildIdentifierLookupTableFromUnicodeRangeTable(
227
227
function _buildIdentifierLookupTableFromSurrogateRangeTable (
228
228
surrogateTable : unicode . UnicodeSurrogateRangeTable ,
229
229
category : CharCategory
230
- ) {
230
+ ) : void {
231
231
for ( const surrogateChar in surrogateTable ) {
232
232
if ( ! _surrogateCharMap [ surrogateChar ] ) {
233
233
_surrogateCharMap [ surrogateChar ] = { } ;
@@ -245,7 +245,7 @@ function _buildIdentifierLookupTableFromSurrogateRangeTable(
245
245
}
246
246
247
247
// Build a lookup table for to speed up tokenization of identifiers.
248
- function _buildIdentifierLookupTable ( fastTableOnly : boolean ) {
248
+ function _buildIdentifierLookupTable ( fastTableOnly : boolean ) : void {
249
249
_identifierCharFastTable . fill ( CharCategory . NotIdentifierChar ) ;
250
250
251
251
_identifierCharRanges . forEach ( ( table ) => {
0 commit comments