-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
334 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
28 changes: 28 additions & 0 deletions
28
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,28 @@ | ||
export function foo(): void {} | ||
foo.apply = () => {} | ||
foo.call = ()=> {} | ||
foo.bind = ()=> {} | ||
foo.caller = ()=> {} | ||
foo.toString = ()=> {} | ||
foo.length = 10 | ||
foo.length = 10 | ||
|
||
export const bar = (): void => {} | ||
bar.apply = () => {} | ||
bar.call = ()=> {} | ||
bar.bind = ()=> {} | ||
bar.caller = ()=> {} | ||
bar.toString = ()=> {} | ||
bar.length = 10 | ||
bar.length = 10 | ||
|
||
export namespace NS { | ||
export const bar = (): void => {} | ||
bar.apply = () => {} | ||
bar.call = ()=> {} | ||
bar.bind = ()=> {} | ||
bar.caller = ()=> {} | ||
bar.toString = ()=> {} | ||
bar.length = 10 | ||
bar.length = 10 | ||
} |
224 changes: 224 additions & 0 deletions
224
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,224 @@ | ||
--- | ||
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 bar: () => 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. | ||
,-[7:1] | ||
6 | export function foo(): void {} | ||
7 | foo.apply = () => {} | ||
: ^^^^^^^^^ | ||
8 | foo.call = ()=> {} | ||
`---- | ||
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. | ||
,-[8:1] | ||
7 | foo.apply = () => {} | ||
8 | foo.call = ()=> {} | ||
: ^^^^^^^^ | ||
9 | foo.bind = ()=> {} | ||
`---- | ||
|
||
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. | ||
,-[9:1] | ||
8 | foo.call = ()=> {} | ||
9 | foo.bind = ()=> {} | ||
: ^^^^^^^^ | ||
10 | foo.caller = ()=> {} | ||
`---- | ||
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:1] | ||
9 | foo.bind = ()=> {} | ||
10 | foo.caller = ()=> {} | ||
: ^^^^^^^^^^ | ||
11 | foo.toString = ()=> {} | ||
`---- | ||
|
||
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. | ||
,-[11:1] | ||
10 | foo.caller = ()=> {} | ||
11 | foo.toString = ()=> {} | ||
: ^^^^^^^^^^^^ | ||
12 | foo.length = 10 | ||
`---- | ||
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. | ||
,-[12:1] | ||
11 | foo.toString = ()=> {} | ||
12 | foo.length = 10 | ||
: ^^^^^^^^^^ | ||
13 | foo.length = 10 | ||
`---- | ||
|
||
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. | ||
,-[13:1] | ||
12 | foo.length = 10 | ||
13 | foo.length = 10 | ||
: ^^^^^^^^^^ | ||
14 | | ||
`---- | ||
|
||
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. | ||
,-[16:1] | ||
15 | export const bar = (): void => {} | ||
16 | bar.apply = () => {} | ||
: ^^^^^^^^^ | ||
17 | bar.call = ()=> {} | ||
`---- | ||
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. | ||
,-[17:1] | ||
16 | bar.apply = () => {} | ||
17 | bar.call = ()=> {} | ||
: ^^^^^^^^ | ||
18 | bar.bind = ()=> {} | ||
`---- | ||
|
||
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. | ||
,-[18:1] | ||
17 | bar.call = ()=> {} | ||
18 | bar.bind = ()=> {} | ||
: ^^^^^^^^ | ||
19 | bar.caller = ()=> {} | ||
`---- | ||
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. | ||
,-[19:1] | ||
18 | bar.bind = ()=> {} | ||
19 | bar.caller = ()=> {} | ||
: ^^^^^^^^^^ | ||
20 | bar.toString = ()=> {} | ||
`---- | ||
|
||
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. | ||
,-[20:1] | ||
19 | bar.caller = ()=> {} | ||
20 | bar.toString = ()=> {} | ||
: ^^^^^^^^^^^^ | ||
21 | bar.length = 10 | ||
`---- | ||
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. | ||
,-[21:1] | ||
20 | bar.toString = ()=> {} | ||
21 | bar.length = 10 | ||
: ^^^^^^^^^^ | ||
22 | bar.length = 10 | ||
`---- | ||
|
||
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. | ||
,-[22:1] | ||
21 | bar.length = 10 | ||
22 | bar.length = 10 | ||
: ^^^^^^^^^^ | ||
23 | | ||
`---- | ||
|
||
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. | ||
,-[26:3] | ||
25 | export const bar = (): void => {} | ||
26 | bar.apply = () => {} | ||
: ^^^^^^^^^ | ||
27 | bar.call = ()=> {} | ||
`---- | ||
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. | ||
,-[27:3] | ||
26 | bar.apply = () => {} | ||
27 | bar.call = ()=> {} | ||
: ^^^^^^^^ | ||
28 | bar.bind = ()=> {} | ||
`---- | ||
|
||
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. | ||
,-[28:3] | ||
27 | bar.call = ()=> {} | ||
28 | bar.bind = ()=> {} | ||
: ^^^^^^^^ | ||
29 | bar.caller = ()=> {} | ||
`---- | ||
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. | ||
,-[29:3] | ||
28 | bar.bind = ()=> {} | ||
29 | bar.caller = ()=> {} | ||
: ^^^^^^^^^^ | ||
30 | bar.toString = ()=> {} | ||
`---- | ||
|
||
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. | ||
,-[30:3] | ||
29 | bar.caller = ()=> {} | ||
30 | bar.toString = ()=> {} | ||
: ^^^^^^^^^^^^ | ||
31 | bar.length = 10 | ||
`---- | ||
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. | ||
,-[31:3] | ||
30 | bar.toString = ()=> {} | ||
31 | bar.length = 10 | ||
: ^^^^^^^^^^ | ||
32 | bar.length = 10 | ||
`---- | ||
|
||
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. | ||
,-[32:3] | ||
31 | bar.length = 10 | ||
32 | bar.length = 10 | ||
: ^^^^^^^^^^ | ||
33 | } | ||
`---- |