Skip to content

Commit e831b6b

Browse files
authored
Add test to make sure .d.ts files are ignored when checking for TypeScript project (facebook#6858)
1 parent a98337c commit e831b6b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/fixtures/issue-5947-not-typescript/index.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test('Ignores node_modules when detecting TypeScript', async () => {
1616
'package',
1717
'index.ts',
1818
];
19+
const dtsSrcPath = [testSetup.testDirectory, 'src', 'types', 'index.d.ts'];
1920
const tsSrcPath = path.join(testSetup.testDirectory, 'src', 'index.ts');
2021

2122
// Step 1.
@@ -28,6 +29,13 @@ test('Ignores node_modules when detecting TypeScript', async () => {
2829
await testSetup.scripts.build();
2930
expect(fs.existsSync(tsConfigPath)).toBe(false);
3031

32+
// Step 1b.
33+
// See if src/types/index.d.ts is treated as a JS project
34+
fs.mkdirSync(path.join(...dtsSrcPath.slice(0, 3)));
35+
fs.writeFileSync(path.join(...dtsSrcPath));
36+
await testSetup.scripts.build();
37+
expect(fs.existsSync(tsConfigPath)).toBe(false);
38+
3139
// Step 2.
3240
// Add TS and ensure tsconfig.json is generated
3341
fs.writeFileSync(tsSrcPath);

0 commit comments

Comments
 (0)