Skip to content

Commit 6ba7e83

Browse files
committed
manage undefined & null keywords
1 parent bd045a3 commit 6ba7e83

File tree

7 files changed

+35
-0
lines changed

7 files changed

+35
-0
lines changed

src/handlers.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ function handle_type_annotation(node, state) {
478478
case 'TSSymbolKeyword':
479479
state.commands.push('symbol');
480480
break;
481+
case 'TSNullKeyword':
482+
state.commands.push('null');
483+
break;
484+
case 'TSUndefinedKeyword':
485+
state.commands.push('undefined');
486+
break;
481487
case 'TSArrayType':
482488
handle_type_annotation(node.elementType, state);
483489
state.commands.push('[]');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let a: string | null = null;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 3,
3+
"names": [],
4+
"sources": [
5+
"input.js"
6+
],
7+
"sourcesContent": [
8+
"let a: string | null = null"
9+
],
10+
"mappings": "IAAI,CAAgB,kBAAG,IAAI"
11+
}

test/samples/ts-null-keyword/input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let a: string | null = null
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let a: number | undefined;
2+
3+
a = 2;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 3,
3+
"names": [],
4+
"sources": [
5+
"input.js"
6+
],
7+
"sourcesContent": [
8+
"let a: number | undefined\na = 2"
9+
],
10+
"mappings": "IAAI,CAAqB;;AACzB,CAAC,GAAG,CAAC"
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let a: number | undefined
2+
a = 2

0 commit comments

Comments
 (0)