Comments (8)
Maybe you need to update to a modern version of TypeScript that is capable of resolving .mjs
modules correctly. See TS config compilerOptions.module
value nodenext
:
https://www.typescriptlang.org/tsconfig#node12nodenext-nightly-builds
from extract-files.
Ok, so I just learned something about TypeScript config after running into a similar weird problem in a project about certain module types being missing, even though it didn't make sense because the module was definitely there and the types can't be missing because they are inside the module as TypeScript JSDoc comments.
The fix was to set compilerOptions.maxNodeModuleJsDepth
to something higher than the 0
default, i.e. 10
. Otherwise TypeScript bails from type checking dependencies of dependencies, and instead of giving a relevant error it just spews an error beginning with TS7016: Could not find a declaration file for module
.
Here is the jsconfig.json
I'm using in projects now:
{
"compilerOptions": {
"maxNodeModuleJsDepth": 10,
"module": "nodenext",
"noEmit": true,
"strict": true
},
"typeAcquisition": {
"enable": false
}
}
from extract-files.
I found the commit related, f34e4b0 and 23fa494
from extract-files.
I fixed by update the import statement:
- import extractFiles from 'extract-files'
+ import extractFiles from 'extract-files/extractFiles.mjs'
And declare ts module for it:
declare module 'extract-files/extractFiles.mjs' {
export default function extractFiles<T>(
values: any,
isExtractableFile?: (value: T) => boolean,
path: string = '',
)
}
also, require the custom File:
export class ReactNativeFile {
readonly uri: string
readonly name: string
readonly type: string
constructor({ uri, name, type }) {
this.uri = uri
this.name = name
this.type = type
}
}
const { clone, files } = extractFiles<ReactNativeFile>(
{
query: req.operation.text,
variables: req.variables,
},
(file) => file instanceof ReactNativeFile,
)
from extract-files.
Glad you figured it out :)
And declare ts module for it
This should not be necessary, because the module has built in TypeScript types via JSDoc:
extract-files/extractFiles.mjs
Lines 8 to 61 in 5232ae9
from extract-files.
The TS compile in my project still complain about missing module. T_T
from extract-files.
Maybe you need to update to a modern version of TypeScript that is capable of resolving
.mjs
modules correctly. See TS configcompilerOptions.module
valuenodenext
:
Thank you, let me try it. Currently, my app still cannot resolve the *.mjs module.
{
"compilerOptions": {
"target": "esnext",
"module": "ESNext"
}
}
from extract-files.
I'm unable to use nodenext
for RN project. So, I think I have to downgrade to version 11. T_T
from extract-files.
Related Issues (20)
- Optional Environment Support beside Browsers/React-Native HOT 2
- Typescript type defs HOT 2
- "No valid exports main found for ..." Error on node 13.3.0 HOT 4
- Handle circular references HOT 3
- Webpack 5 support HOT 2
- package.json uses deprecated subpath folder mappings in exports HOT 8
- Package "extract-files" exists but package.json "exports" does not include entry for "./public/extractFiles" HOT 2
- Add a license file
- imports are broken for @urql/exchange-multipart-fetch HOT 1
- More relaxed engine dep? HOT 2
- Error: Deprecation warning in build HOT 1
- Deprecation Warning HOT 1
- Support Node version 14.4+ HOT 1
- Import issue HOT 10
- FileList handler does not work against a genuine FileList HOT 2
- DeprecationWarning: using version 9.0.0 HOT 1
- Are we able to continue to support non .mjs moving forwards? HOT 1
- Call signatures are incompatible HOT 4
- Document required TypeScript libs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extract-files.