Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use the original class name in the class body (#4827)
* fix: add useOriginalName option * test: add test * test: remove solo * test: set minNodeVersion * refactor: override useOriginalName in ClassDeclaration * test: add more cases * test: tweak description
- Loading branch information
1 parent
48553ca
commit 7c50c18
Showing
19 changed files
with
310 additions
and
5 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
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
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,3 @@ | ||
module.exports = { | ||
description: 'use the original class name instead of renderName in class body' | ||
}; |
36 changes: 36 additions & 0 deletions
36
test/form/samples/use-class-name-in-static-block/_expected/amd.js
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,36 @@ | ||
define((function () { 'use strict'; | ||
|
||
let Test$1 = class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
}; | ||
|
||
class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} | ||
|
||
assert.ok(Test$1.test); | ||
assert.ok(Test.test); | ||
|
||
})); |
34 changes: 34 additions & 0 deletions
34
test/form/samples/use-class-name-in-static-block/_expected/cjs.js
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,34 @@ | ||
'use strict'; | ||
|
||
let Test$1 = class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
}; | ||
|
||
class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} | ||
|
||
assert.ok(Test$1.test); | ||
assert.ok(Test.test); |
32 changes: 32 additions & 0 deletions
32
test/form/samples/use-class-name-in-static-block/_expected/es.js
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,32 @@ | ||
let Test$1 = class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
}; | ||
|
||
class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} | ||
|
||
assert.ok(Test$1.test); | ||
assert.ok(Test.test); |
37 changes: 37 additions & 0 deletions
37
test/form/samples/use-class-name-in-static-block/_expected/iife.js
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,37 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
let Test$1 = class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
}; | ||
|
||
class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} | ||
|
||
assert.ok(Test$1.test); | ||
assert.ok(Test.test); | ||
|
||
})(); |
41 changes: 41 additions & 0 deletions
41
test/form/samples/use-class-name-in-static-block/_expected/system.js
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,41 @@ | ||
System.register([], (function () { | ||
'use strict'; | ||
return { | ||
execute: (function () { | ||
|
||
let Test$1 = class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
}; | ||
|
||
class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} | ||
|
||
assert.ok(Test$1.test); | ||
assert.ok(Test.test); | ||
|
||
}) | ||
}; | ||
})); |
39 changes: 39 additions & 0 deletions
39
test/form/samples/use-class-name-in-static-block/_expected/umd.js
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,39 @@ | ||
(function (factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
factory(); | ||
})((function () { 'use strict'; | ||
|
||
let Test$1 = class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
}; | ||
|
||
class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} | ||
|
||
assert.ok(Test$1.test); | ||
assert.ok(Test.test); | ||
|
||
})); |
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,5 @@ | ||
import { Test } from './test1.js'; | ||
import { Test as Test2 } from './test2.js'; | ||
|
||
assert.ok(Test.test); | ||
assert.ok(Test2.test); |
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,14 @@ | ||
export class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} |
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,14 @@ | ||
export class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
test/function/samples/use-class-name-in-static-block/_config.js
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,4 @@ | ||
module.exports = { | ||
description: 'use the original class name instead of renderName in class body', | ||
minNodeVersion: 16 | ||
}; |
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,5 @@ | ||
import { Test } from './test1.js'; | ||
import { Test as Test2 } from './test2.js'; | ||
|
||
assert.ok(Test.test); | ||
assert.ok(Test2.test); |
14 changes: 14 additions & 0 deletions
14
test/function/samples/use-class-name-in-static-block/test1.js
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,14 @@ | ||
export class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test1'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/function/samples/use-class-name-in-static-block/test2.js
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,14 @@ | ||
export class Test { | ||
constructor() { | ||
assert.ok(Test.test); | ||
assert.ok(this.getText()); | ||
} | ||
getText() { | ||
return Test.test; | ||
} | ||
static test = 'Test2'; | ||
static { | ||
assert.ok(Test.test); | ||
new Test(); | ||
} | ||
} |