Skip to content

Commit ff7866c

Browse files
committed
test(typescript): add test for arbitrary extensions
1 parent b5987c4 commit ff7866c

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import module from './module.custom';
2+
3+
export default module.x;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
x: 5,
3+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare const CustomModule: {
2+
x: Number;
3+
}
4+
export default CustomModule;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"allowArbitraryExtensions": true
4+
},
5+
}

packages/typescript/test/test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,18 @@ test.serial('should not resolve .d.ts files', async (t) => {
496496
t.deepEqual(imports, ['an-import']);
497497
});
498498

499+
test.serial('should not resolve arbitrary .d.<ext>.ts files', async (t) => {
500+
const bundle = await rollup({
501+
input: 'fixtures/arbitrary-dts/main.ts',
502+
plugins: [typescript({ tsconfig: 'fixtures/arbitrary-dts/tsconfig.json' })],
503+
onwarn
504+
});
505+
const arbitraryDeclarationModules = bundle.cache.modules.filter((module) =>
506+
module.id.includes('.d.custom.ts')
507+
);
508+
t.is(arbitraryDeclarationModules.length, 0);
509+
});
510+
499511
test.serial('should transpile JSX if enabled', async (t) => {
500512
process.chdir('fixtures/jsx');
501513

0 commit comments

Comments
 (0)