-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(isolated-declarations): report error for expando functions
- Loading branch information
Showing
4 changed files
with
142 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
15 changes: 15 additions & 0 deletions
15
crates/oxc_isolated_declarations/tests/fixtures/expando-function.ts
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,15 @@ | ||
export function foo(): void {} | ||
foo.apply = () => {} | ||
|
||
export const bar = (): void => {} | ||
bar.call = ()=> {} | ||
|
||
|
||
export namespace NS { | ||
export const goo = (): void => {} | ||
goo.length = 10 | ||
} | ||
|
||
// unexported | ||
const zoo = (): void => {} | ||
zoo.toString = ()=> {} |
44 changes: 44 additions & 0 deletions
44
crates/oxc_isolated_declarations/tests/snapshots/expando-function.snap
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,44 @@ | ||
--- | ||
source: crates/oxc_isolated_declarations/tests/mod.rs | ||
input_file: crates/oxc_isolated_declarations/tests/fixtures/expando-function.ts | ||
--- | ||
==================== .D.TS ==================== | ||
|
||
export declare function foo(): void; | ||
export declare const bar: () => void; | ||
export declare module NS { | ||
export const goo: () => void; | ||
} | ||
|
||
|
||
==================== Errors ==================== | ||
|
||
x TS9023: Assigning properties to functions without declaring them is not | ||
| supported with --isolatedDeclarations. Add an explicit declaration for the | ||
| properties assigned to this function. | ||
,-[10:3] | ||
9 | export const goo = (): void => {} | ||
10 | goo.length = 10 | ||
: ^^^^^^^^^^ | ||
11 | } | ||
`---- | ||
x TS9023: Assigning properties to functions without declaring them is not | ||
| supported with --isolatedDeclarations. Add an explicit declaration for the | ||
| properties assigned to this function. | ||
,-[2:1] | ||
1 | export function foo(): void {} | ||
2 | foo.apply = () => {} | ||
: ^^^^^^^^^ | ||
3 | | ||
`---- | ||
|
||
x TS9023: Assigning properties to functions without declaring them is not | ||
| supported with --isolatedDeclarations. Add an explicit declaration for the | ||
| properties assigned to this function. | ||
,-[5:1] | ||
4 | export const bar = (): void => {} | ||
5 | bar.call = ()=> {} | ||
: ^^^^^^^^ | ||
6 | | ||
`---- |