-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cjs exports has Object.prototype instead of null (#2769)
* fix: cjs exports has Object.prototype instead of null * chore: cleanup
- Loading branch information
1 parent
b666506
commit 4fc492c
Showing
8 changed files
with
36 additions
and
2 deletions.
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,7 @@ | ||
exports.test = () => { | ||
// eslint-disable-next-line no-prototype-builtins | ||
return exports.hasOwnProperty('test') | ||
} | ||
exports.getPrototype = () => { | ||
return Object.getPrototypeOf(exports) | ||
} |
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,2 @@ | ||
export const test: () => boolean | ||
export const getPrototype: () => any |
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 @@ | ||
import { expect, it } from 'vitest' | ||
import * as cjsExports from '../src/prototype.cjs' | ||
|
||
it('has object prototype', () => { | ||
expect(cjsExports.getPrototype()).toBe(Object.prototype) | ||
expect(() => cjsExports.test()).not.toThrow() | ||
expect(cjsExports.test()).toBe(true) | ||
}) |
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 @@ | ||
declare export const test: number |
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 @@ | ||
export const test = 1 |
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 @@ | ||
import { expect, it } from 'vitest' | ||
import * as exports from '../src/prototype.mjs' | ||
|
||
it('prototype is null', () => { | ||
expect(Object.getPrototypeOf(exports)).toBe(null) | ||
expect({}.hasOwnProperty).toBeTypeOf('function') | ||
expect(exports.hasOwnProperty).toBeTypeOf('undefined') | ||
}) |
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