fix(types): EscapableArray
allows supported primitive types
#1072
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purely a TypeScript change. This TypeScript-compiles when part of other projects and I assume that the tests work on it as expected but am not able to execute the unit tests in my environment.
The example in the
Multiple updates in one query
section of the read-me presently reads:Following this, you would expect the below to TypeScript-compile,
and it does.
is set in the
types/index.d.ts
and used in theFirst
type temploid forsql(input)
uses where the input is a primitive array of arrays as above. However, for nested data that isn't juststring
/number
, this does not TypeScript-compile but this is supported by the query-builder itself.For example, changing the
Customer
interface tothe project no longer TypeScript-compiles but if you just transpile ignoring type errors (or make frequent use of
as any
) and then runcreateCustomers([{first_name:"Paris",last_name:"Duval",age:25,mobile:null}])
, it inserts the data just fine (I did not directly test this, it works for my use case and I am almost certain that it would work for this minimal example as it does for the similar example below), thenull
is value accepted just fine.Similarly,
works just fine, printing:
This leads me to believe that this problem is just a discrepancy between the types supported in the TypeScript declarations file and in the JavaScript source. In case this comes up, using
sql.array
does not help here.