Skip to content

tslib: "TypeError: Cannot redefine property:" Bug Appears To Have Returned  #43081

@ghost

Description

Bug Report

Version 1.13.0 fixed the bug referenced here:
microsoft/tslib#102

But, in moving to either 2.0.0 or 2.1.0 - the bug is happening again.

🔎 Search Terms

tslib
TypeError: Cannot redefine property:

🕗 Version & Regression Information

This is fixed in 1.13.0 - but broke again in both version 2.0.0 and 2.1.0

  • This prevents us from using tsconfig aliased paths in conjuncture with jest spyOn(..). We can work around this by providing the relative paths instead of the paths as determined by the tsconfig - but this is against our code policy.
  • This changed between versions 1.13.0 and 2.0.0

💻 Code

internal/business functions/directories scrubbed from the following code snippet - but in case this makes it more clear

import * as Utils from '@some-platform/core/libs/utils/support';

describe( 'test tslib compatibility with aliased imports', () => {

	it( 'jest spyOn', async () => {

		// test that we don't get the following error (tslib 2.0 and 2.1 will cause this):
		// TypeError: Cannot redefine property: foobar
		// at Function.defineProperty (<anonymous>)
		const foobarSpy = jest.spyOn( Utils, 'foobar' );

		const imported = await Utils.foobar( );

		expect( foobarSpy ).toHaveBeenCalled();
	} );
} );

🙁 Actual behavior

We're forced to use relative paths when we use jest spyOn type functionality - instead of the aliased paths from tsconfig.

🙂 Expected behavior

We shouldn't have to update our paths to be relative paths.

Metadata

Metadata

Assignees

Labels

RescheduledThis issue was previously scheduled to an earlier milestoneWorking as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions