diff --git a/test/test-typescript-test.cpp b/test/test-typescript-test.cpp index f06f9082c4..f1f606fb73 100644 --- a/test/test-typescript-test.cpp +++ b/test/test-typescript-test.cpp @@ -278,6 +278,19 @@ TEST(Test_TypeScript_Test, typescript_definition_file) { EXPECT_FALSE(options->jsx); } +TEST(Test_TypeScript_Test, typescript_definition_file_with_weird_extension) { + Padded_String file( + u8"// @filename: example.d.html.ts\n"_sv + u8"export const a;"_sv); + TypeScript_Test_Units units = + extract_units_from_typescript_test(std::move(file), u8"hello.ts"); + ASSERT_EQ(units.size(), 1); + std::optional options = units[0].get_linter_options(); + ASSERT_TRUE(options.has_value()); + EXPECT_TRUE(options->typescript); + EXPECT_TRUE(options->typescript_definition); +} + TEST(Test_TypeScript_Test, javascript_file_is_linted) { { Padded_String file( diff --git a/tools/test-typescript/typescript-test.cpp b/tools/test-typescript/typescript-test.cpp index 4ac2729c99..83df57fe60 100644 --- a/tools/test-typescript/typescript-test.cpp +++ b/tools/test-typescript/typescript-test.cpp @@ -133,7 +133,7 @@ std::optional TypeScript_Test_Unit::get_linter_options() const { if (ends_with(String8_View(this->name), u8".json"_sv)) { return std::nullopt; } - if (ends_with(String8_View(this->name), u8".d.ts"_sv)) { + if (contains(String8_View(this->name), u8".d."_sv)) { return Linter_Options{ .jsx = false, .typescript = true, .typescript_definition = true}; }