Skip to content

Non-null assertions fails to parse with Not a pattern #11142

@mischnic

Description

@mischnic

Describe the bug

This fails to parse, but works fine with TSC: https://www.typescriptlang.org/play/?#code/NwbQhgThYJ4MIHsAONwF0CEAaABJa8yqARpmjgLw4gBQO9eUsiKIp2dD+zR6HaNIA

Input code

;[arrayCopy[currentIndex]!, arrayCopy[randomIndex]!] = [
  arrayCopy[randomIndex]!,
  arrayCopy[currentIndex]!,
]

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es5",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.13.20&code=H4sIAAAAAAAAA7OOTiwqSqx0zi%2BojE6MVdRRQHCTYhVjFWwVorkUUAV1UARAmrhiuQCITKnpSAAAAA%3D%3D&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BCIOhERP9mOVBTl7oUE0maH3xszsA5KwcwGnmotxzIkTYx0ziXhHER%2FSgKSE7IhmwRuvRWu1agd4x5tRwOiaUKpW8j3hoOLkbHjLfM22DH%2FC030iZD5ClZUh8nhVTc0Jfj4XvayfaQ%2B9tA%2F4Ad12XkxWH71TaEFh%2B0LYuVI0xQBAAA%3D

SWC Info output

No response

Expected behavior

[arrayCopy[a], arrayCopy[b]] = [
    arrayCopy[b],
    arrayCopy[a],
];

Actual behavior

fails to parse

Version

1.13.20

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions