Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't ignore properties, when put on a default function in CJS c…
…ontext (#2325) * fix: don't ignore "default" key, when put on a function in CJS context * test: test case for default.default
- Loading branch information
1 parent
30c59f5
commit aa8e662
Showing
4 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict' | ||
|
||
function format() { | ||
return '' | ||
} | ||
|
||
module.exports = format | ||
module.exports.default = format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare function format(): string | ||
|
||
export default format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import format from '../src/default-function.cjs' | ||
|
||
describe('correctly puts default on default', () => { | ||
it('works on default function', () => { | ||
expect(format()).toBe('') | ||
}) | ||
|
||
it('works on nested default function', () => { | ||
// @ts-expect-error types defined only default | ||
expect(format.default()).toBe('') | ||
}) | ||
}) |