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

The deprecated/alias ConnectionOptions type is no longer exported from typeorm #8837

Closed
feather-jmalone opened this issue Apr 1, 2022 · 5 comments · Fixed by #8850
Closed
Labels

Comments

@feather-jmalone
Copy link
Contributor

feather-jmalone commented Apr 1, 2022

Issue Description

Expected Behavior

The ConnectionOptions type is @deprecated as of v0.3.0 (2022-03-17). The Connection type was also marked as @deprecated in this same version, but both types still have 'alias' types for backwards compatibility's sake. This is accomplished by declaring that ConnectionOptions extends DataSourceOptions and Connection extends DataSource, respectively:

image

image

image

While it's great that the intent was to be backwards compatible, the problem is that the ConnectionOptions extends DataSourceOptions class is broken if you try to import it from 'typeorm', because it's not exported in index.d.ts:

image

Actual Behavior

While the Connection->DataSource alias is exported from index.d.ts, the ConnectionOptions->DataSourceOptions alias is not.

The newly renamed types can be imported directly from their class files, if you control the imports at that level. But if you're using NestJS for example (or anything with a TypeORM dependency that hasn't been updated to use the names DataSource or DataSourceOptions yet), the compiler will complain that typeorm has no exported type called ConnectionOptions.

image

The Fix

You can temporarily clear this error by adding the following line to ./node_modules/typeorm/index.d.ts:

export { ConnectionOptions } from "./connection/ConnectionOptions";

But of course, that only solves the problem locally, not for CI/CD or other environments where npm install might need to run again.

[Plus I'm not sure that will completely solve the problem -- the Changelog makes it sound like DataSource and DataSourceOptions are simply just new names for Connection and ConnectionOptions, but is that definitely true? Does the behavior differ at all?]

Steps to Reproduce

Try to initialize a connection using ConnectionOptions with a 3rd party library like NestJS, or any other package that has not updated its TypeORM connection code since the release of v0.3.0 (2022-03-17)

My Environment

  • OSX 11.5.2
  • Node 14.19.1
  • TypeScript 4.6.2
  • TypeORM 0.3.4

Additional Context

N/A

Relevant Database Driver(s)

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql yes
nativescript no
oracle no
postgres no
react-native no
sap no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

NOTE: The above simply means that mysql is the only driver I tried, not that it was the only that had this issue`

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✅ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
@X-neuron
Copy link

X-neuron commented Apr 2, 2022

same problem :

node_modules/@nestjs/typeorm/dist/common/typeorm.decorators.d.ts:2:22 - error TS2724: '"typeorm"' has no exported member named 'ConnectionOptions'. Did you mean 'CollectionOptions'?

2 import { Connection, ConnectionOptions } from 'typeorm';
                       ~~~~~~~~~~~~~~~~~

node_modules/@nestjs/typeorm/dist/common/typeorm.utils.d.ts:3:22 - error TS2724: '"typeorm"' has no exported member named 'ConnectionOptions'. Did you mean 'CollectionOptions'?

3 import { Connection, ConnectionOptions } from 'typeorm';
                       ~~~~~~~~~~~~~~~~~

node_modules/@nestjs/typeorm/dist/interfaces/typeorm-options.interface.d.ts:2:22 - error TS2724: '"typeorm"' has no exported member named 'ConnectionOptions'. Did you mean 'CollectionOptions'?

2 import { Connection, ConnectionOptions } from 'typeorm';
                       ~~~~~~~~~~~~~~~~~

node_modules/@nestjs/typeorm/dist/typeorm.module.d.ts:2:22 - error TS2724: '"typeorm"' has no exported member named 'ConnectionOptions'. Did you mean 'CollectionOptions'?

2 import { Connection, ConnectionOptions } from 'typeorm';

@pleerock
Copy link
Member

pleerock commented Apr 2, 2022

Thanks for the report. Please feel free to PR (just add missing export to index.ts).

@eduardoconti
Copy link

I'm having the same problem with postgres
image

@Zeshan-Shakil
Copy link

i have same issue with mysql n mariadb

@santicortes123
Copy link

tengo otro problema algunos funcionamientos con el Connection, getConnection, createConnection, ConnectionOptions,, no tiene compatibilidad con la version SDK Expo 48.0, hay otra forma para mantener la libreria TypeOrm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants