Skip to content

Commit

Permalink
Merge pull request #161 from backfromexile/import-type
Browse files Browse the repository at this point in the history
use `import type` for type-only imports
  • Loading branch information
nenoNaninu authored Feb 1, 2024
2 parents fad804e + f96704f commit 6e74b24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Tapper/TypeScriptCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void AddHeader(IGrouping<INamespaceSymbol, INamedTypeSymbol> types, ref C

foreach (var groupingType in differentNamespaceTypes)
{
writer.Append($"import {{ {string.Join(", ", groupingType.Select(x => x.Name))} }} from './{groupingType.Key.ToDisplayString()}';{_newLineString}");
writer.Append($"import type {{ {string.Join(", ", groupingType.Select(x => x.Name))} }} from './{groupingType.Key.ToDisplayString()}';{_newLineString}");
}

writer.Append(_newLineString);
Expand Down
8 changes: 4 additions & 4 deletions tests/Tapper.Tests/HeaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public void Test_Header1()
var gt = @"/* THIS (.ts) FILE IS GENERATED BY Tapper */
/* eslint-disable */
/* tslint:disable */
import { CustomType } from './Tapper.Test.SourceTypes.Space1';
import { CustomType2, CustomType3 } from './Tapper.Test.SourceTypes.Space1.Sub';
import { CustomType4 } from './Tapper.Test.SourceTypes.Space2';
import type { CustomType } from './Tapper.Test.SourceTypes.Space1';
import type { CustomType2, CustomType3 } from './Tapper.Test.SourceTypes.Space1.Sub';
import type { CustomType4 } from './Tapper.Test.SourceTypes.Space2';
";

Expand Down Expand Up @@ -96,7 +96,7 @@ public void Test_Header2()
var gt = @"/* THIS (.ts) FILE IS GENERATED BY Tapper */
/* eslint-disable */
/* tslint:disable */
import { CustomType1 } from './Space1';
import type { CustomType1 } from './Space1';
";

Expand Down

0 comments on commit 6e74b24

Please sign in to comment.