Skip to content

add optional chaining and nullish coalescing support#11198

Closed
vankop wants to merge 3 commits intowebpack:masterfrom
vankop:add-optional-chaining
Closed

add optional chaining and nullish coalescing support#11198
vankop wants to merge 3 commits intowebpack:masterfrom
vankop:add-optional-chaining

Conversation

@vankop
Copy link
Copy Markdown
Member

@vankop vankop commented Jul 17, 2020

What kind of change does this PR introduce?

closes #11186
closes #10227

Did you add tests for your changes?

yes

Does this PR introduce a breaking change?

no

What needs to be documented once your changes are merged?

nothing

@webpack-bot
Copy link
Copy Markdown
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)


exports[`StatsTestCases should print correct stats for filter-warnings 1`] = `
"Hash: 2220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff63070922220740a2bcff6307092
"Hash: 73a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd6573a3198368d23afbbd65
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't know why hashes changed

- add handleStrictEqualityComparison callback
- add handleAbstractEqualityComparison callback
- rework evaluateIdentifier interface
- add tests

if (!process.version.startsWith("v14")) return;

const value10 = "" ?? require("fail");
Copy link
Copy Markdown
Member Author

@vankop vankop Jul 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is passing, but since we render "" ?? false need to find a way to load this tests in Node.js < 14. Maybe use babel before load or move this to configCases and handle there with babel.

});

it("should evaluate module.hot to nullish", () => {
if (module.hot ?? true) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I move this to configCases since this does not work with TestCasesHot?

@@ -0,0 +1,5 @@
it("should handle optional members", () => {
expect(
module.hot?.accept((() => {throw new Error("fail")})())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I move this to configCases since this does not work with TestCasesHot?


it("should correctly render defined data #2", () => {
const val1 = _VALUE_?._PROP_?._DEFINED_;
const val2 = _VALUE_?._PROP_?._UNDEFINED_;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I keep this test case? Same problem

Test is passing, but since we render "" ?? false need to find a way to load this tests in Node.js < 14. Maybe use babel before load or move this to configCases and handle there with babel.

devtool: false,
target: "web",
plugins: [
new DefinePlugin({
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import leads to typing errors..

@vankop vankop force-pushed the add-optional-chaining branch from abd8905 to 4bfe6be Compare July 19, 2020 21:38
@webpack-bot
Copy link
Copy Markdown
Contributor

@vankop The most important CI builds failed. This way your PR can't be merged.

Please take a look at the CI results from travis (failure) and appveyor (failure) and fix these issues.

@jfbrennan
Copy link
Copy Markdown

Thanks for this! Looking forward to a merge so I can use vanilla javascript lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[webpack 5] Identifier of ?. is not correctly parsed Unexpected token error at code with optional chaining when using Typescript

3 participants