KCL: No 'let' or 'const' required when declaring vars (#4063)

Previously variable declaration required a keyword, e.g.

```kcl
let x = 4
const x = 4
var x = 4
```

These were all valid, and did the exact same thing. As of this PR, they're all still valid, but the KCL formatter will change them all to just:

```kcl
x = 4
```

which is the new preferred way to declare a constant. 

But the formatter will remove the var/let/const keywords.

Closes https://github.com/KittyCAD/modeling-app/issues/3985
This commit is contained in:
Adam Chalmers
2024-10-02 14:19:40 -05:00
committed by GitHub
parent a24789c236
commit 0c478680cb
160 changed files with 1357 additions and 1360 deletions

View File

@ -2,7 +2,7 @@ import { normaliseKclNumbers } from '../e2e/playwright/test-utils'
test('normaliseKclNumbers', () => {
expect(
normaliseKclNumbers(`const sketch001 = startSketchOn('XY')
normaliseKclNumbers(`sketch001 = startSketchOn('XY')
|> startProfileAt([-10, 10], %)
|> line([20, 0], %)
|> line([0, -20], %)
@ -10,7 +10,7 @@ test('normaliseKclNumbers', () => {
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(-15, sketch001)`)
).toBe(`const sketch001 = startSketchOn('XY')
).toBe(`sketch001 = startSketchOn('XY')
|> startProfileAt([-12.34, 12.34], %)
|> line([12.34, 0], %)
|> line([0, -12.34], %)
@ -20,7 +20,7 @@ const extrude001 = extrude(-15, sketch001)`)
const extrude001 = extrude(-12.34, sketch001)`)
expect(
normaliseKclNumbers(
`const sketch001 = startSketchOn('XY')
`sketch001 = startSketchOn('XY')
|> startProfileAt([-10, 10], %)
|> line([20, 0], %)
|> line([0, -20], %)
@ -30,7 +30,7 @@ const extrude001 = extrude(-12.34, sketch001)`)
const extrude001 = extrude(-15, sketch001)`,
false
)
).toBe(`const sketch001 = startSketchOn('XY')
).toBe(`sketch001 = startSketchOn('XY')
|> startProfileAt([-12.34, 12.34], %)
|> line([12.34, 12.34], %)
|> line([12.34, -12.34], %)