-
Notifications
You must be signed in to change notification settings - Fork 147
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
Integer.d.ts #270
Comments
Hi @janwo, I do not think you need to change imports. Those TypeScript declaration files are just type declarations, right? They do not contain any actual executable JavaScript code and modules. TypeScript knows how to extract types from NPM package and should use those defined in Hope this helps. |
@lutovich When I make no changes to my imports, I get this error message:
Typescript 2.4 |
@janwo this definitely does not sound right. Could you please share an example project to reproduce this problem? |
@lutovich I´ve extracted an example: https://github.com/janwo/neo4j-test
|
@janwo I'm able to make your code compile by changing imports to: import neo4j from "neo4j-driver";
import {Driver} from "neo4j-driver/types/v1/driver";
import Integer from "neo4j-driver/types/v1/integer";
import Record from "neo4j-driver/types/v1/record";
import Transaction from "neo4j-driver/types/v1/transaction";
import Session from "neo4j-driver/types/v1/session";
import {AuthToken} from "neo4j-driver/types/v1"; and public static get(): Driver {
const authToken: AuthToken = neo4j.auth.basic("user", "pwd");
const driver: Driver = neo4j.driver(`bolt://`, authToken);
if(!DatabaseManager.neo4jClient) DatabaseManager.neo4jClient = driver;
return this.neo4jClient;
} I think What do you think? |
I tried this as well. I used that approach when I created this issue. Nevertheless I now pushed the Integer check. And then it does not compile anymore. Actually you are right. There should be no need to change from **/lib/** to **/types/**. |
I'm not entirely sure why this does not work. It has probably something to do with However driver's JS code does not export if(neo4j.isInt(obj)) {
const i = obj as Integer;
console.log('hooray');
} |
But with |
Oh, so it used to work with TypeScript declarations from this PR #183? I'd expect it it work with updated types than, otherwise it's a problem. Do you have an example where |
Yes, the PR is correct. No, sorry. What I meant was the structure of the declaration file of |
have you tried enabling |
It says: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." But all declaration files do have a default export. Also interesting in this case: MikeMcl/bignumber.js#97. Anyway, I got it working with a minor change in integer.d.ts, see my PR. |
having a default export doesn't mean it's an ES module. it's just a commonjs with a if you really don't want to use the |
@pocesar I tried both variants, both did not work. With
and
|
I am using @lutovich approach now.
|
oh my bad, I just noticed you're trying to import the types, and that's not meant to happen. Typescript typings are meant to be side-by-side to their .js counterparts, but neo4j team decided to leave them apart, so yes, your only bet was to copy the types to the lib folder (and it will automatically work). the only way to acquire those internal types would be if @lutovich maybe would be wise to export the interfaces, since they don't mean nothing to the compiled sources, but are useful for people that are consuming and writing libraries that rely on the internals the lines here in https://github.com/neo4j/neo4j-javascript-driver/blob/1.5/types/v1/index.d.ts#L94-L107 would become: export {
driver,
int,
isInt,
integer,
Neo4jError,
auth,
types,
session,
error,
AuthToken,
Session,
Integer, // import Integer, { ... } from './integer' at the top
Config,
Driver // so it would match the forExport const
} |
I can confirm that @pocesar I've tried your last suggestion and it does not seem to help. It is bad to directly import TypeScript declarations, right? Maybe that's another indication they should be moved to Update: TS manual here seem to say it's fine and ok to place declarations in a separate folder. |
the issue is to try and import the declarations without a side-by-side js file to back it up. if you are importing typings just for the sake of accessing interfaces, you need to include the when exporting everything, including interfaces, on the main so the best approach would be, from the |
Do you know when it will make to npm? Because right now it takes trial and error to figure out imports in typescript, this is how ridiculous my imports for neo4j look
the usage is not much better:
|
Fix has been released with 1.4.1 driver which is available on npm. |
I just upgraded to the latest npm package and changed the importings accordingly. However...
...results in a error...
Why?
The text was updated successfully, but these errors were encountered: