Skip to content

Commit dafdcc4

Browse files
committed
Make null produce an IntrinsicNode
1 parent 38913d4 commit dafdcc4

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/parsers/typeResolver.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,14 @@ export function resolveType(
165165
return new IntrinsicNode('undefined');
166166
}
167167

168-
if (type.flags & ts.TypeFlags.Any || type.flags & ts.TypeFlags.Unknown) {
168+
if (type.flags & ts.TypeFlags.Any) {
169169
return new IntrinsicNode('any');
170170
}
171171

172+
if (type.flags & ts.TypeFlags.Unknown) {
173+
return new IntrinsicNode('unknown');
174+
}
175+
172176
if (type.flags & ts.TypeFlags.Literal) {
173177
if (type.isLiteral()) {
174178
return new LiteralNode(
@@ -180,7 +184,7 @@ export function resolveType(
180184
}
181185

182186
if (type.flags & ts.TypeFlags.Null) {
183-
return new LiteralNode('null');
187+
return new IntrinsicNode('null');
184188
}
185189

186190
// TODO: currently types can be either a "function" or an "object" but not both.

test/props-literals/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
{
3535
"name": "nullLiteral",
3636
"type": {
37-
"kind": "literal",
38-
"value": "null"
37+
"kind": "intrinsic",
38+
"name": "null"
3939
},
4040
"optional": false
4141
}

test/react-refs/output.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@
7070
"type": {
7171
"kind": "union",
7272
"types": [
73-
{
74-
"kind": "literal",
75-
"value": "null"
76-
},
7773
{
7874
"kind": "reference",
7975
"name": "RefCallback"
@@ -82,6 +78,10 @@
8278
"kind": "reference",
8379
"name": "RefObject"
8480
},
81+
{
82+
"kind": "intrinsic",
83+
"name": "null"
84+
},
8585
{
8686
"kind": "intrinsic",
8787
"name": "undefined"

test/simple-types/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
{
3535
"name": "n",
3636
"type": {
37-
"kind": "literal",
38-
"value": "null"
37+
"kind": "intrinsic",
38+
"name": "null"
3939
},
4040
"optional": false
4141
}

0 commit comments

Comments
 (0)