Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue committed Nov 19, 2023
1 parent d8a203c commit ed98497
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1633,3 +1633,67 @@ test('should emit declaration files with experimentalDts', async () => {
)
expect(snapshots.sort().join('\n')).toMatchSnapshot()
})

test('should only include exported declarations with experimentalDts', async () => {
const files = {
'package.json': `
{
"name": "tsup-playground",
"private": true,
"version": "0.0.0",
"exports": {
"./entry1": {
"types": "./dist/entry1.d.ts",
"default": "./dist/entry1.js"
},
"./entry2": {
"types": "./dist/entry2.d.ts",
"default": "./dist/entry2.js"
}
}
}
`,
'tsconfig.json': `
{
"compilerOptions": {
"target": "ES2020",
"skipLibCheck": true,
"noEmit": true
},
"include": ["./src"]
}
`,
'tsup.config.ts': `
export default {
name: 'tsup',
entry: {
'entry1': './src/entry1.ts',
'entry2': './src/entry2.ts',
},
}
`,
'src/shared.ts': `
export const declare1 = 'declare1'
export const declare2 = 'declare2'
`,
'src/entry1.ts': `
export { declare1 } from './shared'
`,
'src/entry2.ts': `
export { declare2 } from './shared'
`,
}
const { getFileContent } = await run(getTestName(), files, {
entry: [],
flags: ['--experimental-dts'],
})

let entry1dts = await getFileContent('dist/entry1.d.ts')
let entry2dts = await getFileContent('dist/entry2.d.ts')

expect(entry1dts).toContain('declare1')
expect(entry1dts).not.toContain('declare2')

expect(entry2dts).toContain('declare2')
expect(entry2dts).not.toContain('declare1')
})

0 comments on commit ed98497

Please sign in to comment.