Skip to content
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

Failed build under TypeScript 4.5.2 #499

Closed
fluggo opened this issue Nov 21, 2021 · 3 comments · Fixed by #502
Closed

Failed build under TypeScript 4.5.2 #499

fluggo opened this issue Nov 21, 2021 · 3 comments · Fixed by #502

Comments

@fluggo
Copy link

fluggo commented Nov 21, 2021

Under TypeScript 4.5.2, my tests fail to start with errors like:

21 11 2021 13:35:13.188:ERROR [karma-server]: Error: Unable to resolve module [set] from [/dir/packages/graphlib/lib/graph.spec.js]
21 11 2021 13:35:13.190:ERROR [karma-server]: Error: Unable to resolve module [get] from [/dir/packages/graphlib/lib/graph.spec.js]
21 11 2021 13:35:13.190:ERROR [karma-server]: Error: Unable to resolve module [delete] from [/dir/packages/graphlib/lib/graph.spec.js]

The crux of this problem appears to happen at this line of compiler.ts:

const sourceFile = this.program.getSourceFile(queued.file.originalPath);

Under TypeScript 4.4.4, the resolvedModules property of sourceFile is a true ES6 Map, as far as I can tell.

Under TypeScript 4.5.2, that property has changed to the Map-like ModeAwareCache, which apparently isn't enough like a Map to satisfy whatever comes after this line.

Reverting to TypeScript 4.4 is a workaround.

@holgerd77
Copy link

Yes, we have this problem as well, see issue linked above.

tambien added a commit to Tonejs/Tone.js that referenced this issue Dec 9, 2021
typescript can't be updated bc of this issue it seems like: monounity/karma-typescript#499
kibertoad added a commit to kibertoad/toad-scheduler that referenced this issue Dec 12, 2021
kibertoad added a commit to kibertoad/toad-scheduler that referenced this issue Dec 12, 2021
@sedlakr
Copy link

sedlakr commented Dec 16, 2021

Solution is to implement better Map check on line if (lodash.isMap(resolvedModules)) { // Typescript 2.2+

for new ModeAwareCache lodash.isMap is evaluated as false and it will go into else branch which is wrong

Some easy fix is to create primitive ModeAwareCache check function like

var isTS45Map = function(map){
return typeof map.get === "function" &&
typeof map.set === "function" &&
typeof map.delete === "function" &&
typeof map.has === "function" &&
typeof map.forEach === "function" &&
typeof map.size === "function";
}

and use it on the line like

if (isTS45Map(resolvedModules) || lodash.isMap(resolvedModules)) { // Typescript 2.2+

@sedlakr
Copy link

sedlakr commented Dec 16, 2021

I created my own scoped package with fix https://www.npmjs.com/package/@sedlak.r/karma-typescript/v/5.5.2-issue499fix.2
If you are familiar with lockfile, you can change karma-typescript lockfile entry somehow like this for Yarn:

karma-typescript@^5.5.2:
version "5.5.2"
resolved "https://registry.yarnpkg.com/@sedlak.r/karma-typescript/-/karma-typescript-5.5.2-issue499fix.2.tgz#44300c12aff4b618f770d5530c7e2764ab0e5158"
integrity sha512-wmcetaplK95YK7Rd3Yyv9BFRJImSe+V/yAaGqDCoQlbP+xYwHWW7yUdCNFn3Wkn+y0YwWESYMU1X4ozzKf/z7w==

bhovhannes added a commit to Workfront/workfront-api that referenced this issue Jan 10, 2022
karma-typescript is not working with TS 4.5.4, thus downgraded to TS 4.4.4 until this will be fixed. See monounity/karma-typescript#499 for more details.
citizensas pushed a commit to Workfront/workfront-api that referenced this issue Jan 10, 2022
* refactor: upgrade deps, switch to lefthook, fix tests

karma-typescript is not working with TS 4.5.4, thus downgraded to TS 4.4.4 until this will be fixed. See monounity/karma-typescript#499 for more details.

* test: remove IE11 and Linux Chrome 48 from test matrix, as those are outdated browsers

* test: transpile fetch-mock bundle to es5 syntax to make ancient browsers happy

fetch-mock's client-legacy-bundle was throwing an exception during execution.

* test: remove IE11 and non-chromium Edge browsers from test matrix as they are dead

* test: make tests work for latest browsers

* test: make tests work for latest browsers
dgp1130 added a commit to dgp1130/blog that referenced this issue Aug 6, 2022
Also bumps `karma-typescript` to latest to address monounity/karma-typescript#499.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants