Skip to content

Commit

Permalink
chore(deps): upgrade typescript to 5.1.6 (#4718)
Browse files Browse the repository at this point in the history
This release includes various refinements and improvements. One thing if
fixes is an issue where previously an exported class declaration that
included a static property would be not have the export keyword put
directly on the class declaration, but instead the symbol would be
exported.

So with the following typescript:

```ts
export class MyClass {
  static foobar: string = "baz";
}
```

the compiler would emit code like this:

```js
class MyClass {
  static foobar = "baz";
}
export { MyClass }
```

instead of

```js
export class MyClass {
  static foobar = "baz;
}
```

The former output causes an issue with Rollup, so that issue being fixed
is part of the impetus for this upgrade.

Try this out [here on the TS
playground](https://www.typescriptlang.org/play?useDefineForClassFields=true&target=9&ts=5.1.6&ssl=1&ssc=1&pln=3&pc=1#code/KYDwDg9gTgLgBAYwDYEMDOa4GFUbgbwFgAoOMuNGFGASwTgDNoBbAQQwgRuuABM4AvHBhQArsADcJAL5A)
to confirm (toggle between version 5.1 and 5.2 and look at the change in
output).

See <https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-1.html>
for a full list of changes and improvements.

Co-authored-by: Ryan Waskiewicz <ryanwaskiewicz@gmail.com>
  • Loading branch information
alicewriteswrongs and rwaskiewicz committed Aug 24, 2023
1 parent 4fd1b28 commit 49df0e7
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 320 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"semver": "^7.3.7",
"sizzle": "^2.3.6",
"terser": "5.19.2",
"typescript": "~5.0.4",
"typescript": "~5.1.6",
"webpack": "^5.75.0",
"ws": "8.13.0"
},
Expand Down
2 changes: 1 addition & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{
// TODO(STENCIL-710): Increment this value as a part of updating TypeScript
matchPackageNames: ['typescript'],
allowedVersions: '<5.0.0',
allowedVersions: '<5.1.6',
},
{
// disable Jest updates until the new testing architecture is in place
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/component-lazy/lazy-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const updateLazyComponentClass = (
cmp: d.ComponentCompilerMeta,
) => {
const members = updateLazyComponentMembers(transformOpts, styleStatements, classNode, moduleFile, cmp);
return updateComponentClass(transformOpts, classNode, classNode.heritageClauses, members, moduleFile);
return updateComponentClass(transformOpts, classNode, classNode.heritageClauses, members);
};

const updateLazyComponentMembers = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const updateNativeComponentClass = (
): ts.ClassDeclaration | ts.VariableStatement => {
const heritageClauses = updateNativeHostComponentHeritageClauses(classNode, moduleFile);
const members = updateNativeHostComponentMembers(transformOpts, classNode, moduleFile, cmp);
return updateComponentClass(transformOpts, classNode, heritageClauses, members, moduleFile);
return updateComponentClass(transformOpts, classNode, heritageClauses, members);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@ import { augmentDiagnosticWithNode, buildError } from '@utils';
import ts from 'typescript';

import type * as d from '../../../declarations';
import {
convertValueToLiteral,
createStaticGetter,
retrieveTsDecorators,
retrieveTsModifiers,
} from '../transform-utils';
import { retrieveTsDecorators, retrieveTsModifiers } from '../transform-utils';
import { componentDecoratorToStatic } from './component-decorator';
import { hasStaticInitializerInClass } from './convert-static-members';
import { isDecoratorNamed } from './decorator-utils';
import {
CLASS_DECORATORS_TO_REMOVE,
Expand Down Expand Up @@ -88,14 +82,6 @@ const visitClassDeclaration = (
listenDecoratorsToStatic(diagnostics, decoratedMembers, filteredMethodsAndFields);
}

// Handle static members that are initialized
const hasStaticMembersWithInit = classMembers.some(hasStaticInitializerInClass);
if (hasStaticMembersWithInit) {
filteredMethodsAndFields.push(
createStaticGetter('stencilHasStaticMembersWithInit', convertValueToLiteral(hasStaticMembersWithInit)),
);
}

// We call the `handleClassFields` method which handles transforming any
// class fields, removing them from the class and adding statements to the
// class' constructor which instantiate them there instead.
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/compiler/transformers/remove-static-meta-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const REMOVE_STATIC_GETTERS = new Set([
'methods',
'states',
'originalStyleUrls',
'stencilHasStaticMembersWithInit',
'styleMode',
'style',
'styles',
Expand Down
1 change: 0 additions & 1 deletion src/compiler/transformers/static-to-meta/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const parseStaticComponentMeta = (
componentClassName: cmpNode.name ? cmpNode.name.text : '',
elementRef: parseStaticElementRef(staticMembers),
encapsulation,
hasStaticInitializedMember: getStaticValue(staticMembers, 'stencilHasStaticMembersWithInit') ?? false,
shadowDelegatesFocus: parseStaticShadowDelegatesFocus(encapsulation, staticMembers),
properties: parseStaticProps(staticMembers),
virtualProperties: parseVirtualProps(docs),
Expand Down
217 changes: 0 additions & 217 deletions src/compiler/transformers/test/convert-static-members.spec.ts

This file was deleted.

Loading

0 comments on commit 49df0e7

Please sign in to comment.