File tree Expand file tree Collapse file tree
tests/baselines/reference/transformApi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4319,7 +4319,7 @@ namespace ts {
43194319 const namespaceDeclaration = getNamespaceDeclarationNode ( node ) ;
43204320 if ( namespaceDeclaration && ! isDefaultImport ( node ) ) {
43214321 const name = namespaceDeclaration . name ;
4322- return isGeneratedIdentifier ( name ) ? name : createIdentifier ( getSourceTextOfNodeFromSourceFile ( sourceFile , namespaceDeclaration . name ) ) ;
4322+ return isGeneratedIdentifier ( name ) ? name : createIdentifier ( getSourceTextOfNodeFromSourceFile ( sourceFile , name ) || idText ( name ) ) ;
43234323 }
43244324 if ( node . kind === SyntaxKind . ImportDeclaration && ( < ImportDeclaration > node ) . importClause ) {
43254325 return getGeneratedNameForNode ( node ) ;
Original file line number Diff line number Diff line change @@ -192,6 +192,38 @@ namespace ts {
192192 } ;
193193 }
194194 } ) ;
195+
196+ // https://github.com/Microsoft/TypeScript/issues/19618
197+ testBaseline ( "transformAddImportStar" , ( ) => {
198+ return ts . transpileModule ( "" , {
199+ transformers : {
200+ before : [ transformAddImportStar ] ,
201+ } ,
202+ compilerOptions : {
203+ target : ts . ScriptTarget . ES5 ,
204+ module : ts . ModuleKind . System ,
205+ newLine : NewLineKind . CarriageReturnLineFeed ,
206+ }
207+ } ) . outputText ;
208+
209+ function transformAddImportStar ( _context : ts . TransformationContext ) {
210+ return ( sourceFile : ts . SourceFile ) : ts . SourceFile => {
211+ return visitNode ( sourceFile ) ;
212+ } ;
213+ function visitNode ( sf : ts . SourceFile ) {
214+ // produce `import * as i0 from './comp';
215+ const importStar = ts . createImportDeclaration (
216+ /*decorators*/ undefined ,
217+ /*modifiers*/ undefined ,
218+ /*importClause*/ ts . createImportClause (
219+ /*name*/ undefined ,
220+ ts . createNamespaceImport ( ts . createIdentifier ( "i0" ) )
221+ ) ,
222+ /*moduleSpecifier*/ ts . createLiteral ( "./comp1" ) ) ;
223+ return ts . updateSourceFileNode ( sf , [ importStar ] ) ;
224+ }
225+ }
226+ } ) ;
195227 } ) ;
196228}
197229
Original file line number Diff line number Diff line change 1+ System . register ( [ "./comp1" ] , function ( exports_1 , context_1 ) {
2+ var __moduleName = context_1 && context_1 . id ;
3+ var i0 ;
4+ return {
5+ setters : [
6+ function ( i0_1 ) {
7+ i0 = i0_1 ;
8+ }
9+ ] ,
10+ execute : function ( ) {
11+ }
12+ } ;
13+ } ) ;
You can’t perform that action at this time.
0 commit comments