File tree Expand file tree Collapse file tree 5 files changed +89
-0
lines changed
.changeset/silver-dots-exercise Expand file tree Collapse file tree 5 files changed +89
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "releases" : [{ "name" : " extract-react-types" , "type" : " minor" }],
3+ "dependents" : [
4+ {
5+ "name" : " babel-plugin-extract-react-types" ,
6+ "type" : " patch" ,
7+ "dependencies" : [" extract-react-types" ]
8+ },
9+ {
10+ "name" : " extract-react-types-loader" ,
11+ "type" : " patch" ,
12+ "dependencies" : [" extract-react-types" ]
13+ },
14+ { "name" : " kind2string" , "type" : " patch" , "dependencies" : [" extract-react-types" ] },
15+ {
16+ "name" : " pretty-proptypes" ,
17+ "type" : " patch" ,
18+ "dependencies" : [" kind2string" , " extract-react-types" ]
19+ }
20+ ]
21+ }
Original file line number Diff line number Diff line change 1+ Adds support for TypeScript's as expression.
Original file line number Diff line number Diff line change @@ -3889,6 +3889,55 @@ Object {
38893889}
38903890` ;
38913891
3892+ exports [` ts as expression 1` ] = `
3893+ Object {
3894+ " component" : Object {
3895+ " kind" : " generic" ,
3896+ " name" : Object {
3897+ " kind" : " id" ,
3898+ " name" : " Component" ,
3899+ " type" : null ,
3900+ },
3901+ " value" : Object {
3902+ " kind" : " object" ,
3903+ " members" : Array [
3904+ Object {
3905+ " default" : Object {
3906+ " kind" : " string" ,
3907+ " value" : " foo" ,
3908+ },
3909+ " key" : Object {
3910+ " kind" : " id" ,
3911+ " name" : " bar" ,
3912+ },
3913+ " kind" : " property" ,
3914+ " optional" : false ,
3915+ " value" : Object {
3916+ " kind" : " generic" ,
3917+ " value" : Object {
3918+ " kind" : " union" ,
3919+ " referenceIdName" : " Foo" ,
3920+ " types" : Array [
3921+ Object {
3922+ " kind" : " string" ,
3923+ " value" : " foo" ,
3924+ },
3925+ Object {
3926+ " kind" : " string" ,
3927+ " value" : " bar" ,
3928+ },
3929+ ],
3930+ },
3931+ },
3932+ },
3933+ ],
3934+ " referenceIdName" : " Props" ,
3935+ },
3936+ },
3937+ " kind" : " program" ,
3938+ }
3939+ ` ;
3940+
38923941exports [` ts boolean 1` ] = `
38933942Object {
38943943 " component" : Object {
Original file line number Diff line number Diff line change @@ -1188,6 +1188,10 @@ converters.TSThisType = (path, context): K.This => {
11881188 return { kind : 'custom' , value : 'this' } ;
11891189} ;
11901190
1191+ converters . TSAsExpression = ( path , context ) : K . Param => {
1192+ return convert ( path . get ( 'expression' ) , context ) ;
1193+ } ;
1194+
11911195function extendedTypesMembers ( path , context ) {
11921196 const members = path . get ( 'extends' ) ;
11931197 if ( ! members || ! members . length ) {
Original file line number Diff line number Diff line change @@ -503,6 +503,20 @@ const TESTS = [
503503 }
504504 `
505505 } ,
506+ {
507+ name : 'ts as expression' ,
508+ typeSystem : 'typescript' ,
509+ code : `
510+ type Foo = 'foo' | 'bar';
511+ type Props = { bar: Foo }
512+
513+ class Component extends React.Component<Props> {
514+ static defaultProps = {
515+ bar: 'foo' as Foo,
516+ }
517+ }
518+ `
519+ } ,
506520 {
507521 name : 'ts object' ,
508522 typeSystem : 'typescript' ,
You can’t perform that action at this time.
0 commit comments