@@ -57,11 +57,30 @@ describe("transpiling basic types", () => {
5757 "export type T = number | string | Record<string, boolean>" ,
5858 "from typing_extensions import Dict, Union\n\nT = Union[str,float,Dict[str,bool]]" ,
5959 ] ,
60+ [
61+ "export type T = number | undefined" ,
62+ // without strict mode the `undefined` gets lost here
63+ "T = float" ,
64+ ] ,
6065 ] ) ( "transpiles %p to %p" , async ( input , expected ) => {
6166 const result = await transpileString ( input ) ;
6267 expect ( result ) . toEqual ( expected ) ;
6368 } ) ;
6469
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+
6584 it ( "only transpiles exported types" , async ( ) => {
6685 const result = await transpileString ( `
6786 type NotExported = number;
0 commit comments