Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #74 from spahnke/nullish-coalesce
Browse files Browse the repository at this point in the history
[JS/TS] Add support for the nullish-coalesce operator
  • Loading branch information
alexdima committed Dec 16, 2019
2 parents 307c82d + aff86cc commit 4370bf5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/javascript/javascript.test.ts
Expand Up @@ -725,6 +725,33 @@ testTokenization('javascript', [
}],


[{
line: 'test ? 1 : 2',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'delimiter.js' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'number.js' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.js' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'number.js' },
]
}],

[{
line: 'couldBeNullish ?? 1',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'delimiter.js' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'number.js' }
]
}],


[{
line: '`${5 + \'x\' + 3}a${4}`',
tokens: [
Expand Down
27 changes: 27 additions & 0 deletions src/typescript/typescript.test.ts
Expand Up @@ -745,6 +745,33 @@ testTokenization('typescript', [
}],


[{
line: 'test ? 1 : 2',
tokens: [
{ startIndex: 0, type: 'identifier.ts' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'delimiter.ts' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'number.ts' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.ts' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'number.ts' },
]
}],

[{
line: 'couldBeNullish ?? 1',
tokens: [
{ startIndex: 0, type: 'identifier.ts' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'delimiter.ts' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'number.ts' }
]
}],


[{
line: '`${5 + \'x\' + (<any>)3}a${4}`',
tokens: [
Expand Down
2 changes: 1 addition & 1 deletion src/typescript/typescript.ts
Expand Up @@ -91,7 +91,7 @@ export const language = {
operators: [
'<=', '>=', '==', '!=', '===', '!==', '=>', '+', '-', '**',
'*', '/', '%', '++', '--', '<<', '</', '>>', '>>>', '&',
'|', '^', '!', '~', '&&', '||', '?', ':', '=', '+=', '-=',
'|', '^', '!', '~', '&&', '||', '??', '?', ':', '=', '+=', '-=',
'*=', '**=', '/=', '%=', '<<=', '>>=', '>>>=', '&=', '|=',
'^=', '@',
],
Expand Down

0 comments on commit 4370bf5

Please sign in to comment.