Skip to content

fix: update TypeScript to v5.5 #5898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 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 @@ -181,7 +181,7 @@
"semver": "^7.3.7",
"terser": "5.31.1",
"tsx": "^4.10.3",
"typescript": "~5.4.0",
"typescript": "~5.5.3",
"webpack": "^5.75.0",
"ws": "8.17.1"
},
Expand Down
4 changes: 2 additions & 2 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{
// Increment this value as a part of updating TypeScript
matchPackageNames: ['typescript'],
allowedVersions: '<5.5.0',
allowedVersions: '<5.6.0',
commitMessagePrefix: "feat(typescript):"
},
{
Expand Down Expand Up @@ -152,7 +152,7 @@
rebaseWhen: 'never',
/**
* Cron syntax to run at midnight (UTC) on the first day of every month
*
*
* Note: Renovate does not support minute value granularity, so the wildcard value is necessary
*/
schedule: ["* 0 1 * *"],
Expand Down
21 changes: 2 additions & 19 deletions scripts/esbuild/utils/typescript-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export async function bundleTypeScriptSource(tsPath: string, opts: BuildOptions)
} catch (e) {}

// get the source typescript.js file to modify
console.log('READ', tsPath);

let code = await fs.readFile(tsPath, 'utf8');

// As of 5.0, because typescript is now bundled with esbuild the structure of
Expand Down Expand Up @@ -74,25 +76,6 @@ export async function bundleTypeScriptSource(tsPath: string, opts: BuildOptions)
const jestTypesciptFilename = join(opts.scriptsBuildDir, 'typescript-modified-for-jest.js');
await fs.writeFile(jestTypesciptFilename, code);

// Here we transform the TypeScript source from a commonjs to an ES module.
// We do this so that we can add an import from the `@environment` module.

// trim off the last part that sets module.exports and polyfills globalThis since
// we don't want typescript to add itself to module.exports when in a node env
const tsEnding = `if (typeof module !== "undefined" && module.exports) { module.exports = ts; }`;

if (!code.includes(tsEnding)) {
throw new Error(`"${tsEnding}" not found`);
}
const lastEnding = code.lastIndexOf(tsEnding);
code = code.slice(0, lastEnding);

const o: string[] = [];
o.push(`// TypeScript ${opts.typescriptVersion}`);
o.push(code);
o.push(`export default ts;`);
code = o.join('\n');

Comment on lines -77 to -95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, what changed so we don't need this anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TypeScript team made changes to make it easier consumable for ESM packages (see announcement). I tested it with an .mjs file, e.g.

import * as foo from './node_modules/typescript/lib/typescript.js'

console.log(foo);

And it worked great.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

// TODO(STENCIL-839): investigate minification issue w/ typescript 5.0
// const { minify } = await import('terser');

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/proxy-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ export const proxyComponent = (
} else if (
prototype.hasOwnProperty(propName) &&
typeof this[propName] === 'number' &&
this[propName] == newValue
// cast type to number to avoid TS compiler issues
this[propName] == (newValue as unknown as number)
) {
// if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
// APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/package-lock.json

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