score:19
The error message was actually very misleading, and looks like a typescript bug.
It appears that enums
can't be exported directly, it seems necessary to use a const
to be able to export them correctly.
So I modified my enum
declaration like so
declare module 'seeyouftp' {
// exporting a const instead of
export const enum AuthStates {
success = 'success',
error = 'error'
}
}
Everything works now but that error message is very, very bad and time consuming
score:0
You need to create seeyouftp
(I assum that seeyouftp
is your js module name) folder under /definitions
and have types.d.ts
inside /definitions/seeyouftp
like structure below
|— definitions
|—seeyouftp
|— index.d.ts
|— entries
|— fonts
|— less
|— src
And update your tsconfig
"typeRoots": [
"./assets/definitions",
"./node_modules/@types"
],
score:0
Because it is a webpack issue, you have to update your webpack config. Webpack needs to be told where to find the module seeyouftp
:
// webpack.config.js
const path = require('path');
module.exports = {
//...
resolve: {
// Add an alias
alias: {
'seeyouftp': path.resolve(__dirname, 'definitions/types.d.ts')
}
}
};
For the path to the file types.d.ts
I assumed your webpack configuration is located next to the definitions
folder.
Here is the associated webpack documentation.
score:1
Try to export the declarations, and see if that makes a difference:
declare module 'seeyouftp' {
export interface User {
admin: boolean;
roles: string[];
username: string;
}
export enum AuthStates {
success = 'success',
error = 'error'
}
Source: stackoverflow.com
Related Query
- Typescript Module not found Can't resolve
- How to fix this error : " Module not found :can't resolve popper.js "
- "module not found : Error: Cannot resolve module 'react/lib/ReactMount' "
- Material-UI components not found during TypeScript module resolution
- Module not found Error: Can't resolve 'history' in @types/history
- Cannot resolve module "firebase" from 'firebase.js' : Firebase could not be found within the project
- Module not found: Error: Can't resolve 'react-select' with typescript
- How to resolve module not found error in webpack/reactjs app?
- Module not found: Error: Can't resolve 'crypto' and Cant resolve 'fs'
- Module not found, Cant resolve serviceWorker in 'React'
- Module not found: Error: Can't resolve the typescript file when adding typescript to a CRA app
- Module not found with corresponding type declarations using Typescript with Next.js
- Typescript own module not found
- Can't resolve module not found in React.js
- Module not found Can't resolve react-scroll-to-bottom
- React:Unable to resolve path to module and intellisense in my own typescript react moudle does not working
- Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type
- Module not found: Can't resolve '@emotion/react'
- Failed to compile. Module not found: Can't resolve 'react-router-dom'
- Module not found: Can't resolve 'fs' in Next.js application
- Module not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css' in 'C:\react-form-validation-demo\src'
- Webpack + React + TypeScript: Module not found ... in ... node_modules/react/
- Module not found: Can't resolve 'swiper/react'
- Module not found: Can't resolve '@date-io/date-fns'
- Module not found: Can't resolve 'material-ui/AutoComplete'
- Module not found: Can't resolve '@emotion/react' in 'E:\frontend\node_modules\@mui\styled-engine'
- React unable to import component -- module not found
- How to fix - Module not found: Can't resolve '@babel/runtime/helpers/objectWithoutPropertiesLoose'
- Module not found: Can't resolve '@mui/material/utils' : (v5, which included a name change.)
- How to resolve "Animated: `useNativeDriver` is not supported because the native animated module is missing." in react-navigation?
More Query from same tag
- How to update a function with useEffect (like componentDidUpdate) and use .map function to display from JSON file ReactJS
- Why does adding extra arrow function parentheses resolve an infinite loop problem?
- React - 'react-d3-graph' not rendering Chart component
- React 0.14.2 error - Super expression must either be null or a function
- problem creating a reusable filtered table using React
- React/Node Uncaught SyntaxError: Unexpected token <
- How to use 2 different values of 'THIS' in React
- Shallow test component, complain about required props gotten from mapStateToProps and mapDispatchToProps
- How to render component by referring its string type of name?
- React Router v4 - Error: React.Children.only expected to receive a single React element child
- Load new jsx renders into existing Div
- Why can't string variable be used in <Image source={}/>? (React Native)
- React router is just showing a blank page after I structure like the şmage below
- this.props.chatVisible is 'undefined'
- How to change swipe direction in swiper.js?
- history.push redirect overrides the the path I set to different one
- I am unable to fetch data from this API. Here is the code
- Tell if shift is being held in onClick in React
- Component re-renders because of unused property in context
- Why does my Create React App Dev Server take so long to start?
- Force a re-render (update the state and update the DOM) immediately with react.js
- Selecting one row in table without using extra npm packages
- React Firebase problem: which is the most efficient way to save a variable?
- Cannot find name React$Node React Native
- How Can I Filter the data using Search Field
- How can I render multiple components interpolating JSX?
- How to disable prefixes in Emotion 11 in development?
- React route - logout cannot redirect to correct page
- HTML file input accept .zip files also includes .xlsx, pptx, .docx
- How to pass multiple queries into refetchQueries in apollo/graphql