Typescript-TDD / ts-auto-mock

Typescript transformer to unlock automatic mock creation for interfaces and classes
https://typescript-tdd.github.io/ts-auto-mock
MIT License
600 stars 16 forks source link

Typescript 5.2.2 : TypeError: DeprecationError: 'originalKeywordKind' has been deprecated since v5.0.0 and can no longer be used. #1497

Closed JeanBeaurepaire closed 9 months ago

JeanBeaurepaire commented 10 months ago

Subject of the issue

When I'm using ts-auto-mock with Typescript 5.2.2, I have this issue:

TypeError: DeprecationError: 'originalKeywordKind' has been deprecated since v5.0.0 and can no longer be used. Use 'identifierToKeywordKind(identifier)' instead.

      at node_modules/typescript/lib/typescript.js:171860:13
      at IdentifierObject.<anonymous> (node_modules/typescript/lib/typescript.js:171890:7)
      at t.GetIdentifierDescriptor (node_modules/ts-auto-mock/transformer/index.js:1:21455)
      at t.GetDescriptor (node_modules/ts-auto-mock/transformer/index.js:1:14165)
      at t.GetPropertyDescriptor (node_modules/ts-auto-mock/transformer/index.js:1:38211)

Your environment

Steps to reproduce

Use ts-auto-mock with Typescript > 5.2.2

Expected behavior

No compile errors.

Actual behavior

Above error

uittorio commented 10 months ago

Hey, I've just played a bit to add support for typescript 5.2 and greater. 99% of the stuff works except since version 5.1.X there is something nasty happening :(

if you mock using typeof, the compiled code is struggling to get reference imports correctly.

import {createMock} from 'ts-auto-mock';
import {Hello} from "./hello";

it('should work', () => {
  console.log(Hello);
  const type: any = createMock<typeof Hello>();
  expect(type.a).toBe("s");
});

console log shows undefined :(

This is only happening when using createMock, it's definitely something weird that we are doing!

I'll see if I get around it during the holidays! Merry Christmas

uittorio commented 10 months ago

It should now be fixed! Try the latest version!

uittorio commented 9 months ago

I'll close this issue! Feel free to open another issue if the problem persists!