Skip to content

Commit

Permalink
Update to TypeScript 5.2 (#276)
Browse files Browse the repository at this point in the history
* Update to TypeScript 5.2 by default

Drop support for TypeScript 4.4

Prepare to release v2.0.0

* Update dependencies and lint clean.

* Update husky config.

* Format

* Ignore test snapshots.

* Add exhaustive switch check.

* Update changelog.
  • Loading branch information
rictic authored Oct 18, 2023
1 parent b47529a commit 9a21c8b
Show file tree
Hide file tree
Showing 23 changed files with 1,927 additions and 5,847 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Install Dev
if: steps.cache-dev.outputs.cache-hit != 'true'
run: npm ci
working-directory: 'dev'
working-directory: "dev"

- name: Test
run: npm run test:all
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx eslint --fix
npx prettier --write .
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
test/snapshots/
18 changes: 10 additions & 8 deletions ANALYZE.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,28 +189,30 @@ In addition, the entire content of HTMLElement is copied into the interfaces, so

### Component discovery

An LWC component class is automatically identified from a JavaScript/Typescript file if:
An LWC component class is automatically identified from a JavaScript/Typescript file if:

- It is the default export of the file
- The JS file name equals the parent folder name (ex: `/../mycomp/mycomp.{js|ts}`)
- There is an HTML template with the same name in the same folder (ex: `/../mycomp/mycomp.html`)
- There is an HTML template with the same name in the same folder (ex: `/../mycomp/mycomp.html`)

The component is named after the last 2 parts of its parent directory. For example, if the file path is
`/../myns/mycomp/mycomp.js`, then the component tag is `myns-mycomp`. The name is also transformed from camel case
to dash case: `/../myns/mycomp/myComp.js` leads to `myns-my-comp`.
to dash case: `/../myns/mycomp/myComp.js` leads to `myns-my-comp`.

For components that are not following the previous naming scheme, it uses 2 other methods:

For components that are not following the previous naming scheme, it uses 2 other methods:
- Checks if the class extends `LightningElement`.
This only works with a direct inheritance as it doesn't check the whole hierarchy.
This only works with a direct inheritance as it doesn't check the whole hierarchy.

- Looks for a `@lwcelement` JSDoc tag.
The JSDoc tag can also override the default tag name.
The JSDoc tag can also override the default tag name.

```javascript
/**
* @lwcelement my-element
*/
export default class MyElement extends BaseComponent {
```
```
#### In your own code
Expand Down Expand Up @@ -249,4 +251,4 @@ export default class MyElement extends LightningElement {
*/
@api prop3;
}
```
```
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/)
<!-- ### Removed -->
<!-- ### Fixed -->

## [2.0.0] - 2023-10-18

- Drop support for TypeScript pre-4.8. Testing with versions:
4.8, 4.9, 5.0, 5.1, 5.2

## [2.0.0-next.5] - 2023-06-12

- Drop support for 3.x versions of TypeScript. Testing with versions:
Expand Down
524 changes: 262 additions & 262 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/src/lit-element/lit-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MyElement extends LitElement {
};
}

update(changedProperties: Map<PropertyKey, unknown>): void {
update(changedProperties) {
super.update();
}

Expand Down
Loading

0 comments on commit 9a21c8b

Please sign in to comment.