Skip to content

Commit

Permalink
support for satisfies op
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Nov 21, 2022
1 parent 64ef074 commit da8cc13
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
20 changes: 20 additions & 0 deletions lib/utils/indent-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,26 @@ function defineVisitor({
expressionTokens.firstToken
)
},
/**
* Process satisfies expression
*
* e.g.
* ```
* var foo = bar satisfies Bar
* // ^^^^^^^^^^^^^^^^^
* ```
*/
TSSatisfiesExpression(node) {
const expressionTokens = getFirstAndLastTokens(node.expression)
const satisfiesToken = tokenStore.getTokenAfter(
expressionTokens.lastToken
)
setOffset(
[satisfiesToken, getFirstAndLastTokens(node.typeAnnotation).firstToken],
1,
expressionTokens.firstToken
)
},
/**
* Process type reference
*
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@types/node": "^13.13.5",
"@types/semver": "^7.3.9",
"@types/xml-name-validator": "^4.0.0",
"@typescript-eslint/parser": "^5.43.0",
"@typescript-eslint/parser": "^5.44.0",
"@vuepress/plugin-pwa": "^1.9.7",
"acorn": "^8.7.1",
"env-cmd": "^10.1.0",
Expand All @@ -87,7 +87,7 @@
"mocha": "^10.0.0",
"nyc": "^15.1.0",
"prettier": "^2.6.2",
"typescript": "^4.6.4",
"typescript": "^4.9.3",
"vue-eslint-editor": "^1.1.0",
"vuepress": "^1.9.7"
}
Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/script-indent/ts-satisfies-operators-01.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!--{"parserOptions": {"parser":"@typescript-eslint/parser"}, "requirements": { "@typescript-eslint/parser": ">=5.44.0" } }-->
<script lang="ts">
var a =
{} satisfies
Foo
var b =
{} satisfies Bar
</script>

0 comments on commit da8cc13

Please sign in to comment.