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

Property 'Client' does not exist and Namespace has no exported member 'Transaction' #24

Open
Michael-Xie opened this issue Jun 28, 2021 · 1 comment

Comments

@Michael-Xie
Copy link

Expected Result

use of snowflake connection should connect to snowflake database

Actual Result

a bunch of type error

Steps to reproduce

	"dependencies": {
		"@azure/cosmos": "^3.11.5",
		"@types/node": "^14.17.4",
		"adal-node": "^0.2.2",
		"aws-sdk": "^2.936.0",
		"date-fns": "^2.22.1",
		"date-fns-tz": "^1.1.4",
		"express-jwt": "^6.0.0",
		"express-jwt-authz": "^2.4.1",
		"guid": "0.0.12",
		"jwks-rsa": "^2.0.3",
		"knex": "^0.95.6",
		"knex-snowflake-dialect": "^0.2.5",
		"mongodb": "^3.6.9",
		"mssql": "^6.3.2",
		"node-fetch": "^2.6.1",
		"pg": "^8.6.0",
		"quick-pivot": "^2.7.0",
		"tedious": "^11.0.9",
		"ts-jest": "^26.5.6"
	},
	"devDependencies": {
		"@azure/functions": "^1.2.3",
		"@types/jest": "^26.0.23",
		"@typescript-eslint/eslint-plugin": "^4.28.1",
		"@typescript-eslint/parser": "^4.28.1",
		"cz-conventional-changelog": "^3.3.0",
		"eslint": "^7.29.0",
		"eslint-config-airbnb-base": "^14.2.1",
		"eslint-config-prettier": "^6.15.0",
		"eslint-plugin-import": "^2.23.4",
		"eslint-plugin-prettier": "^3.4.0",
		"husky": "^4.3.8",
		"jest": "^26.6.3",
		"lint-staged": "^10.5.4",
		"nodemon": "^2.0.7",
		"prettier": "^2.3.2",
		"pretty-quick": "^3.1.1",
		"standard-version": "^9.3.0",
		"stub-azure-function-context": "^2.0.0-alpha.6",
		"typescript": "^4.3.4"
	},
  1. Run Azure function
// eslint-disable-next-line import/no-unresolved
import { AzureFunction, Context, HttpRequest } from '@azure/functions';
import { SnowflakeDialect } from 'knex-snowflake-dialect';


const knex = require('knex')({
	client: SnowflakeDialect as any,
	connection: process.env.SNOWFLAKE_CONNECTION_STRING,
	pool: {
		min: 1,
		max: 1,
	},
});

const httpTrigger: AzureFunction = async function (
	context: Context,
	req: HttpRequest,
): Promise<void> {
	try {
		if (!req.body) throw new Error('no request body');

		const db = knex;
		console.log({ db });

		const result = {};

		context.res = {
			status: 200,
			body: result,
		};
	} catch (err) {
		context.log.error(err);
		context.res = {
			status: 500,
			body: err,
		};
	}
};

export default httpTrigger;

Visual Proof (screenshots, videos, text)


node_modules/knex-snowflake-dialect/lib/index.d.ts:5:52 - error TS2339: Property 'Client' does not exist on type 'typeof import("/home/xiemicha/projects/portal-api/node_modules/knex/types/index")'.

5 export declare class SnowflakeDialect extends Knex.Client {
                                                     ~~~~~~

node_modules/knex-snowflake-dialect/lib/index.d.ts:11:66 - error TS2694: Namespace '"/home/xiemicha/projects/portal-api/node_modules/knex/types/index"' has no exported member 'Transaction'.

11     transaction(container: any, config: any, outerTx: any): Knex.Transaction;
@melohagan
Copy link
Contributor

I think it's related, but I can't use the dialect as shown in the README:

client = knex({ client: SnowflakeDialect })

Screenshot 2022-05-31 at 16 07 23

Would love for this to be fixed.

@melohagan melohagan mentioned this issue May 31, 2022
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

No branches or pull requests

2 participants