From e6368c9e629140f832a18c0bfeb17fb671d2e6f6 Mon Sep 17 00:00:00 2001 From: sher Date: Mon, 25 Mar 2024 22:27:41 +0900 Subject: [PATCH 1/3] added ts-ignore to import statements --- src/Kiota.Builder/Writers/TypeScript/CodeUsingWriter.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeUsingWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeUsingWriter.cs index f205f4af2f..7fdbfd4ca0 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeUsingWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeUsingWriter.cs @@ -26,7 +26,10 @@ public void WriteCodeElement(IEnumerable usings, CodeNamespace parent .GroupBy(static x => x.Path) .OrderBy(static x => x.Key); foreach (var codeUsing in importSymbolsAndPaths.Where(static x => !string.IsNullOrWhiteSpace(x.Key))) + { + writer.WriteLine("// @ts-ignore"); writer.WriteLine($"import {{ {codeUsing.Select(static x => GetAliasedSymbol(x.Symbol, x.Alias, x.ShouldUseTypeImport)).Distinct().OrderBy(static x => x).Aggregate(static (x, y) => x + ", " + y)} }} from '{codeUsing.Key}';"); + } writer.WriteLine(); } From 2549950e965c6e4a8d0873168e519b09d4b916e3 Mon Sep 17 00:00:00 2001 From: sher Date: Tue, 26 Mar 2024 07:01:27 +0900 Subject: [PATCH 2/3] updated relevant unit tests --- .../Writers/TypeScript/CodeUsingWriterTests.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeUsingWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeUsingWriterTests.cs index 60cea77fa8..0071f095f6 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeUsingWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeUsingWriterTests.cs @@ -41,6 +41,7 @@ public void WritesAliasedSymbol() }; usingWriter.WriteCodeElement(new CodeUsing[] { us }, root, writer); var result = tw.ToString(); + Assert.Contains("// @ts-ignore", result); Assert.Contains("import { Bar as baz } from", result); } [Fact] @@ -62,6 +63,7 @@ public void DoesntAliasRegularSymbols() }; usingWriter.WriteCodeElement(new CodeUsing[] { us }, root, writer); var result = tw.ToString(); + Assert.Contains("// @ts-ignore", result); Assert.Contains("import { Bar } from", result); } @@ -86,6 +88,7 @@ public void WritesImportTypeStatementForGeneratedInterfaces() }; usingWriter.WriteCodeElement(new CodeUsing[] { us }, root, writer); var result = tw.ToString(); + Assert.Contains("// @ts-ignore", result); Assert.Contains("import { type Bar } from", result); } @@ -109,6 +112,7 @@ public void WritesImportTypeStatementForDenotedExternalLibraries() }; usingWriter.WriteCodeElement(new CodeUsing[] { us }, root, writer); var result = tw.ToString(); + Assert.Contains("// @ts-ignore", result); Assert.Contains("import { type Bar } from", result); } @@ -132,6 +136,7 @@ public void WritesImportTypeStatementForRequestConfiguration() }; usingWriter.WriteCodeElement(new CodeUsing[] { us }, root, writer); var result = tw.ToString(); + Assert.Contains("// @ts-ignore", result); Assert.Contains("import { type Bar } from", result); } @@ -155,6 +160,7 @@ public void WritesImportTypeStatementForQueryParameters() }; usingWriter.WriteCodeElement(new CodeUsing[] { us }, root, writer); var result = tw.ToString(); + Assert.Contains("// @ts-ignore", result); Assert.Contains("import { type Bar } from", result); } @@ -178,6 +184,7 @@ public void WritesImportTypeStatementForModel() }; usingWriter.WriteCodeElement(new CodeUsing[] { us }, root, writer); var result = tw.ToString(); + Assert.Contains("// @ts-ignore", result); Assert.Contains("import { type Bar } from", result); } } From 7d0b0dfc7c5e50b0c1c8b898b03c3e4cd620b5c5 Mon Sep 17 00:00:00 2001 From: sher Date: Tue, 26 Mar 2024 07:06:30 +0900 Subject: [PATCH 3/3] updated CHANGELOG --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e109a7f170..5ef449d8dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a warning message in the CLI when using preview languages. [#4316](https://github.com/microsoft/kiota/issues/4316) - Added support for handling untyped Json content in C#,Golang, TypeScript and Java. [#2319](https://github.com/microsoft/kiota/issues/2319) +- Added TypeScript typecheck suppression to `.ts` files where unused imports cause build fail in projects which use `noUnusedLocals: true` compiler option. [#4397](https://github.com/microsoft/kiota/issues/4397) ### Changed @@ -96,7 +97,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Java - Self-extraction of query parameters instead of using reflection. [#3965](https://github.com/microsoft/kiota/issues/3965) +- Java - Self-extraction of query parameters instead of using reflection. [#3965](https://github.com/microsoft/kiota/issues/3965) - Fixed a bug where the discriminator validation rule would report false positives on nullable union types. - Fixed a bug where constructors and model names where clashing in Go. [#3920](https://github.com/microsoft/kiota/issues/3920) - Fixed a bug where the order of enum declaration might results in a missing enum type. [#3935](https://github.com/microsoft/kiota/issues/3935)