Closed OmgImAlexis closed 2 years ago
Switching to import sqlite3 from 'better-sqlite3';
for this specific library does allow tsup
to build.
I guess you don't need to bundle types from node_modules right? I can make that disabled by default to fix it..
Actually I kinda like being able to bundle all my types for production.
For example i have a few deps they’re dynamically imported and are optional but I’d still like their types available.
Having an option to disable might be good for some users though.
Got hit with this again. Seems like a parsing issue on tsup
's side since the import itself works and intellisense even shows it.
For example this is the typing showing for the following import yet we still get the error thrown.
(alias) type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void
import NextHandleFunction
import { NextHandleFunction } from 'connect';
Error: 'NextHandleFunction' is not exported by node_modules/@types/connect/index.d.ts, imported by node_modules/@types/body-parser/index.d.ts
at error (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:161:30)
at Module.error (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:15097:16)
at handleMissingExport (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:14994:28)
at Module.traceVariable (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:15478:24)
at ModuleScope.findVariable (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:14047:39)
at FunctionScope.findVariable (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:9527:38)
at Identifier$1.bind (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:9938:40)
at AssignmentPattern.bind (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:9571:23)
at AssignmentPattern.bind (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:11615:15)
at FunctionDeclaration.bind (/Users/xo/code/unraid/core/node_modules/rollup/dist/shared/rollup.js:9567:31)
Seems rollup-plugin-dts doesn't support exportEqual namespace yet?:
// types.d.ts
declare namespace Foo {
export const bar: string
}
export = Foo
This doesn't work:
import { bar } from './types'
I've opened an issue over there. https://github.com/Swatinem/rollup-plugin-dts/issues/93
Actually I kinda like being able to bundle all my types for production.
Please don‘t do that. :-D:-D
Sometimes the things from @types
have really strange idioms in them, and its a nightmare to work with.
This example in particular. I think, this is whats going on:
namespace
as an opaque "item". Due to declaration merging, you can have namespaces which have the same name as functions, which is basically the same as having an interface with members and a call signature.module.exports = fn_with_props
require
that, since the result is just any kind of value..d.ts
world. And TBH, I don‘t want to, since its something that is fundamentally different when using ES modules.Please don‘t do that. :-D:-D
@Swatinem it may not make sense in all cases but in my specific case it makes a lot of sense since it's an internal library and I'm specifically pulling in types from those modules to type my interfaces.
This actually works because TS uses structural typing. With nominal typing, you would have to re-export the actual thing from your external library, otherwise you wouldn’t be able to use that stuff. Anyway, I digress
Either way is there a possibility of this being fixed?
FYI I disabled this by default in the latest version
Either way is there a possibility of this being fixed?
I don‘t think an equivalent to "import default interop" is possible in dts. Or at least I wouldn’t know how.
I'm hitting this error in a different package (fast-json-stringify
). What do I need to do to avoid the error?
FYI I disabled this by default in the latest version
@egoist what setting is this? Maybe the project I'm working in turned it back on?
This line causes the following error.
This is the
better-sqlite3
definition file it's referencing.