@@ -57,11 +57,30 @@ describe("transpiling basic types", () => {
57
57
"export type T = number | string | Record<string, boolean>" ,
58
58
"from typing_extensions import Dict, Union\n\nT = Union[str,float,Dict[str,bool]]" ,
59
59
] ,
60
+ [
61
+ "export type T = number | undefined" ,
62
+ // without strict mode the `undefined` gets lost here
63
+ "T = float" ,
64
+ ] ,
60
65
] ) ( "transpiles %p to %p" , async ( input , expected ) => {
61
66
const result = await transpileString ( input ) ;
62
67
expect ( result ) . toEqual ( expected ) ;
63
68
} ) ;
64
69
70
+ it . each ( [
71
+ [
72
+ "export type T = number | undefined" ,
73
+ "from typing_extensions import Union\n\nT = Union[None,float]" ,
74
+ ] ,
75
+ [
76
+ "export type T = number | null" ,
77
+ "from typing_extensions import Union\n\nT = Union[None,float]" ,
78
+ ] ,
79
+ ] ) ( "transpiles %p to %p when strict" , async ( input , expected ) => {
80
+ const result = await transpileString ( input , { } , { strict : true } ) ;
81
+ expect ( result ) . toEqual ( expected ) ;
82
+ } ) ;
83
+
65
84
it ( "only transpiles exported types" , async ( ) => {
66
85
const result = await transpileString ( `
67
86
type NotExported = number;
0 commit comments