File tree 3 files changed +46
-1
lines changed
tests/baselines/reference/transformApi
3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -4319,7 +4319,7 @@ namespace ts {
4319
4319
const namespaceDeclaration = getNamespaceDeclarationNode ( node ) ;
4320
4320
if ( namespaceDeclaration && ! isDefaultImport ( node ) ) {
4321
4321
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 ) ) ;
4323
4323
}
4324
4324
if ( node . kind === SyntaxKind . ImportDeclaration && ( < ImportDeclaration > node ) . importClause ) {
4325
4325
return getGeneratedNameForNode ( node ) ;
Original file line number Diff line number Diff line change @@ -192,6 +192,38 @@ namespace ts {
192
192
} ;
193
193
}
194
194
} ) ;
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
+ } ) ;
195
227
} ) ;
196
228
}
197
229
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