I tried to type my own code. But when I’m typing
import org.apache.commons.lang.StringUtils;
import au.com.bytecode.opencsv.CSVReader;
It always show an error in eclipse.
I downloaded the java project, and it works fine.
The source is here
http://viralpatel.net/blogs/java-load-csv-file-to-database/comment-page-1/#comment-41747
I'm wondering is there any extra steps that I need to do to make this work?
Related
So I have been trying to import JSON Simple (https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1)
I am also using Visual Studio Code. So I have added the dependency in my pom.xml file, but it still wont find my imports. Do I have to add soemthing to my module-info? (fixed a different issue for me) I tried requires com.json.simple; or requires com.googlecode.json.simple; but I get the cannot be resolved to a module error. Also my project is a javafx Application, that implements server socket networks (JSON exchage).
Im at a complete los here on what to do...
Thanks for your help.
So after a lot of trial and error, i have finally fixed it. Instead of vs code I used IntelliJ and added the dependencies there. Its impotant to note, that after every import I had to restart intelliJ also make sure to press the icon as mentioned in this tutorial https://www.jetbrains.com/help/idea/work-with-maven-dependencies.html#maven_import_dependency.
Currently, I upgrade my Angular project form 8 to 9.
The project's using a "#types/moment-timezone": "^0.5.30" in package.json
Now this package has been deprecated. https://www.npmjs.com/package/#types/moment-timezone
When I run the project ng serve, it shows up this error message
user.model.ts:3:25 - error TS7016: Could not find a declaration file for module 'moment-timezone'. '/home/bunthai/sftp/upgrade/projectg/ui/ctr/node_modules/moment-timezone/index.js' implicitly has an 'any' type.
Try `npm install #types/moment-timezone` if it exists or add a new declaration (.d.ts) file containing `declare module 'moment-timezone';`
import * as moment from 'moment-timezone';
~~~~~~~~~~~~~~~~~
How to deal with this problem?
I've found the solution: https://stackoverflow.com/a/42505940/10258377
In my case change from import * as moment from 'moment-timezone' to const moment = require('moment-timezone');
You need to remove this import, and import your wanted timezone manualy eg:
import moment from "moment";
import "moment/locale/fr";
moment.locale('fr')
If you don't import another timezone, you'll get the default nodeJS server timezone. If you want another, you need to import it and use it.
Just and advice, stop using this library if you can.
I am using React (16.12.0) with PhpStorm (2019.3.1).
The package I am importing is react-router-dom (5.1.2)
I will write the following import:
import { NavLink, Switch } from "react-router-dom";
Both packages are imported properly by webpack/babel and the page renders properly when I use both Switch and NavLink.
However purely from the IDE-perspective, I get a warning about Switch: Cannot resolve symbol 'Switch'
It is weird because it is obviously there, and I checked in /node_modules/react-router-dom and Switch.js is there.
Strangely on previous versions of PhpStorm (before several updates and plugin imports and other changes), the Switch import was accurately found by PhpStorm.
I have not updated react-router-dom recently and am using its latest stable build.
Any ideas as to why it might be missing Switch?
EDIT:
I have realized it may be because PhpStorm is having difficulty importing a commonJS module.
I tried changing the Javascript compilation method from React JSX to ECMA 6. That didn't work.
I also tried importing some build libraries for react-router-dom, and that worked for recognizing the Route import strangely but not Switch.
I also tried invalidating the PhpStorm cache and restarting the app, but that didn't work either.
EDIT 2:
Per an answer, I have tried to use option+enter (alt+enter on windows) while my cursor is within react-router-dom to try to install a typescript package, but I don't get the same suggested action as shown on the JetBrains website: https://www.jetbrains.com/help/webstorm/configuring-javascript-libraries.html
All it suggests is switching single quotes to double quotes.
Also I have already installed #types/react-router-dom. Perhaps there is another one that I am missing?
EDIT 3:
The correct answer was to install #types/react-router. For some reason #types/react-router-dom is deceivingly NOT what solves this.
node_modules/react-router-dom/esm/react-router-dom.js exports BrowserRouter, HashRouter, Link and NavLink, but doesn't export Switch, it's not explicitly defined there.
For better completion/type hinting, you can install Typescript stubs for the package: put cursor on "react-router-dom" in import statement, hit Alt+Enter, choose Install TypeScript definitions for better type information::
See https://www.jetbrains.com/help/webstorm/2019.3/configuring-javascript-libraries.html#ws_jsconfigure_libraries_ts_definition_files
Currently I am trying to use the OfficeExtension.Promise polyfill offered by Microsoft for developing Office Add-Ins. Unfortunately I am not able to get it to work thus far. From what I can tell these are only offered in the WordApi 1.2 and ExcelApi 1.2. Since I could not find separate node modules offering these api's I presume that these are included in the normal '#microsoft/office-js' node module. Additionally I have installed the office-js types as well.
Node modules
Import statements
So far I have tried importing the 'OfficeExtension' class/namespace in the following ways.
import {OfficeExtension} from '#microsoft/office-js'
import {OfficeExtension} from 'office-js'
import {OfficeExtension} from '#types/office-js'
Error
All of these result in an intellisense error stating that the module cannot be found.
Question
The concrete problem is that I do not know how to import the functionality in order to use the OfficeExtension.Promise polyfill. I could find no documentation that offers any help on this topic, so any advice or information would be greatly appreciated.
Unfortunately the error that is shown, actually states what is happening. 'office-js' does not export a module that can be used in a Typescript/React project. Office or OfficeExtension are global variables on the 'Window'. Therefore a /// tag or another script reference is needed, in order to import these variables.
Link
I'd like my imports to be more fail-fast. I want my build process to fail if someone tries to import something that does not exist.
For default imports it seems to work fine, as the following will fail:
import Something from "doesNotExist";
But if I import an attribute of an existing module, it does not fail:
import React, {BadKey} from "react";
How can I make it fail by default?
I'm using Webpack / Babel5 / NPM 2.14
Use a strongly-typed language like Typescript, which can error in this condition. We actually moved to eliminate all our default exports and imports, because the name checking available for import { Thing } is super helpful.
If you're already using Webpack, eslint-loader is one way to integrate with ESLint as part of your build process.
Webpack can be a little cryptic with errors during module builds, though, so take note of the NoErrorsPlugin at the bottom of the README.
Also, consider using Webpack's bail flag (set to true) to abandon building as soon as module errors are encountered. IIRC the default Webpack behavior just omits the error-ing module from the emitted bundle with a note in the console, which will result in a runtime error anyway (module missing).