Skip to content

Commit

Permalink
Merge pull request #630 from simonihmig/update-ts
Browse files Browse the repository at this point in the history
Update TypeScript to latest
  • Loading branch information
ef4 authored Aug 27, 2024
2 parents a1e9144 + 6a3673c commit b423901
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 49 deletions.
170 changes: 134 additions & 36 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 packages/ember-auto-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"quick-temp": "^0.1.8",
"qunit": "^2.17.2",
"qunit-assertions-extra": "^0.8.5",
"typescript": "4.3.5"
"typescript": "5.5.3"
},
"engines": {
"node": "12.* || 14.* || >= 16"
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-auto-import/ts/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class Analyzer extends Funnel {
try {
transformSync(source, options);
} catch (err) {
if (err.name !== 'SyntaxError') {
if (err instanceof Error && err.name !== 'SyntaxError') {
throw err;
}
debug('Ignoring an unparseable file');
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-auto-import/ts/tests/analyzer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ Qmodule('analyzer', function (hooks) {
throw new Error(`expected not to get here, build was supposed to fail`);
} catch (err) {
assert.contains(
err.message,
err instanceof Error ? err.message : String(err),
'import() is only allowed to contain string literals or template string literals'
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-auto-import/ts/tests/splitter-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Qmodule('splitter', function (hooks) {
throw new Error(`expected not to get here, build was supposed to fail`);
} catch (err) {
assert.contains(
err.message,
err instanceof Error ? err.message : String(err),
'Dynamic imports must target unambiguous package names'
);
}
Expand All @@ -333,7 +333,7 @@ Qmodule('splitter', function (hooks) {
throw new Error(`expected not to get here, build was supposed to fail`);
} catch (err) {
assert.contains(
err.message,
err instanceof Error ? err.message : String(err),
'Dynamic imports must target unambiguous package names'
);
}
Expand All @@ -349,7 +349,7 @@ Qmodule('splitter', function (hooks) {
throw new Error(`expected not to get here, build was supposed to fail`);
} catch (err) {
assert.contains(
err.message,
err instanceof Error ? err.message : String(err),
`ember-auto-import does not support dynamic relative imports. "./thing" is relative. To make this work, you need to upgrade to Embroider.`
);
}
Expand Down
12 changes: 6 additions & 6 deletions packages/ember-auto-import/ts/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { join, dirname, resolve, relative, posix, isAbsolute } from 'path';
import { createHash } from 'crypto';
import { mergeWith, flatten, zip } from 'lodash';
import { writeFileSync, realpathSync, readFileSync } from 'fs';
import { compile, registerHelper } from 'handlebars';
import Handlebars from 'handlebars';
import jsStringEscape from 'js-string-escape';
import { BundleDependencies, ResolvedTemplateImport } from './splitter';
import { BuildResult, Bundler, BundlerOptions } from './bundler';
Expand All @@ -32,8 +32,8 @@ const EXTENSIONS = ['.js', '.ts', '.json'];

const debug = makeDebug('ember-auto-import:webpack');

registerHelper('js-string-escape', jsStringEscape);
registerHelper('join', function (list, connector) {
Handlebars.registerHelper('js-string-escape', jsStringEscape);
Handlebars.registerHelper('join', function (list, connector) {
return list.join(connector);
});

Expand All @@ -56,9 +56,9 @@ function idToModule(id: string) {
return moduleIdMap.get(id) ?? id;
}

registerHelper('module-to-id', moduleToId);
Handlebars.registerHelper('module-to-id', moduleToId);

const entryTemplate = compile(
const entryTemplate = Handlebars.compile(
`
module.exports = (function(){
var d = _eai_d;
Expand Down Expand Up @@ -441,7 +441,7 @@ export default class WebpackBundler extends Plugin implements Bundler {
return callback(undefined, 'commonjs ' + request);
}
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
if ((err as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {
throw err;
}
// real package doesn't exist, so externalize it
Expand Down
2 changes: 1 addition & 1 deletion test-scenarios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@types/qunit": "^2.11.1",
"qunit": "^2.6.1",
"ts-node": "^9.1.1",
"ts-node": "^10.9.2",
"scenario-tester": "^2.1.2",
"jsdom": "^11.11.0"
},
Expand Down

0 comments on commit b423901

Please sign in to comment.