joshwooding / vite-plugin-react-docgen-typescript

MIT License
8 stars 7 forks source link

ts.JsxEmit.React is undefined within options.mjs #22

Open danvim opened 1 year ago

danvim commented 1 year ago

I believe the built dist/chunks/options.mjs code might have some issues, namely the TypeScript import. You might want to check all mjs files.

From debugging:

import * as ts from 'typescript';

ts.JsxEmit // undefined
ts.default.JsxEmit // object
image

test.mjs

import * as ts from 'typescript'

console.log('ts.JsxEmit', ts.JsxEmit)
console.log('ts.default.JsxEmit', ts.default.JsxEmit)

Run results

$ node test.mjs
ts.JsxEmit undefined
ts.default.JsxEmit {
  '0': 'None',
  '1': 'Preserve',
  '2': 'React',
  '3': 'ReactNative',
  '4': 'ReactJSX',
  '5': 'ReactJSXDev',
  None: 0,
  Preserve: 1,
  React: 2,
  ReactNative: 3,
  ReactJSX: 4,
  ReactJSXDev: 5
}
rogerluiz commented 1 year ago

im with the same error, any workaround?

joshwooding commented 1 year ago

What version of typescript are you using?

danvim commented 1 year ago

version 5.0.4

danvim commented 1 year ago

im with the same error, any workaround?

@rogerluiz The fix should be import ts from 'typescript' instead of the asterisk import. But only monkey patching the lib code would work.

andrewmozolev commented 1 year ago

I have just got the same error with typescript 5.2.2. Do you have any suggestions on how to work around the problem?