Swatinem / rollup-plugin-dts

A rollup plugin to generate .d.ts rollup files for your typescript project
GNU Lesser General Public License v3.0
812 stars 71 forks source link

[@types/node | undici-types] UnsupportedSyntaxError: ImportEquals should have a literal source. #314

Open kravetsone opened 4 months ago

kravetsone commented 4 months ago

Checklist

Code Snipped

import type { Response } from "undici-types";

export type A = Response;

Error Message

UnsupportedSyntaxError: ImportEquals should have a literal source.

4:1: `import MockDispatch = MockInterceptor.MockDispatch;`   
    at dr.convertImportDeclaration (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:10590)
    at dr.convertStatement (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:8366)     
    at new Transformer (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:7064)
    at convert (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:6881)
    at Object.transform (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:27:14853)       
    at handleDtsFile (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:30:1244)
    at Object.transform (Z:\PROJECTS\node-ts\test\node_modules\pkgroll\dist\rollup-plugin-dts-BzOer96X.js:30:1843)        
    at Z:\PROJECTS\node-ts\test\node_modules\rollup\dist\shared\rollup.js:989:40 {
  code: 'PLUGIN_ERROR',
  plugin: 'dts',
  hook: 'transform',
  id: 'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-agent.d.ts',
  watchFiles: [
    'Z:\\PROJECTS\\node-ts\\test\\src\\index.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\index.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\cache.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\filereader.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\file.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\formdata.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\fetch.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-errors.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-agent.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-pool.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-client.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\api.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\global-dispatcher.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\agent.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\errors.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\connector.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\client.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\balanced-pool.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\interceptors.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\handlers.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\pool.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\dispatcher.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\global-origin.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\proxy-agent.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\cookies.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\diagnostics-channel.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\websocket.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\content-type.d.ts',
    'Z:\\PROJECTS\\node-ts\\test\\node_modules\\undici-types\\mock-interceptor.d.ts'
  ]
}

undici-types used by @types/node and in dependencies source code it looks like import("undici-types").Response

kravetsone commented 1 month ago

still occured(

kravetsone commented 1 month ago

as a workaraound for:

const response = new Response("ok"); // error ar build time like in issue

u can cast it type to Response and idk why it solve the issue

const response = new Response("ok") as Response; // no error at build time