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

Type error in module breaking my build #416

Open
patrickbenjamin1 opened this issue May 10, 2020 · 2 comments
Open

Type error in module breaking my build #416

patrickbenjamin1 opened this issue May 10, 2020 · 2 comments

Comments

@patrickbenjamin1
Copy link

Just switched over to using this on a new project, and there's a typescript error coming out of this module, from lib/types.d.ts.

	interface TableDefinition<Name extends string, Row> {
		name: Name;
		schema: string;
                 // FROM THIS LINE
		columns: {[CName in keyof Row]: ColumnDefinition<CName, Row[CName]>};
		dialect?: SQLDialects;
		isTemporary?: boolean;
		foreignKeys?: {
			table: string,
			columns: (keyof Row)[],
			refColumns: string[],
			onDelete?: 'restrict' | 'cascade' | 'no action' | 'set null' | 'set default';
			onUpdate?: 'restrict' | 'cascade' | 'no action' | 'set null' | 'set default';
		}
	}

as that keyof is inferred as 'string' | 'number' | 'symbol', and ColumnDefinition is expecting just a string for that generic.

I can solving it temporarily by telling typescript to ignore errors in node_modules, but that's not ideal.

@zzh948498
Copy link

I had the same problem!

@khmseu
Copy link

khmseu commented Dec 24, 2020

The line should be
columns: {[CName in Extract< keyof Row, string >]: ColumnDefinition<CName, Row[CName]>};
That was a breaking change in Typescript some time in the 3.8/3.9 versions.

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

3 participants