regexFind: /import\s*\{\s*([A-Z][a-zA-Z0-9_$]*)\s*\}\s*from\s*['"][^'"]+['"]/
regexReplace: // @ts-ignore
// import { $1 } from './types' // Use JSDoc insteadConvert TypeScript type imports to JSDoc type annotations in JavaScript files. Use @typedef or inline JSDoc comments instead of import statements for types.
- import { MyType } from './types'
+ /** @typedef {Object} MyType
+ * @property {string} name
+ */
const value = { name: 'test' }Explanation: Replace type import with JSDoc typedef
- import { User, Product } from './types'
+ /** @typedef {Object} User
+ * @typedef {Object} Product
+ */
+ /** @param {User} user */
function processUser(user) { }Explanation: Replace multiple type imports with JSDoc typedefs
npx tsc ./docs/18042/index.js --noEmit --pretty --allowJs --checkJsdocs/18042/index.js:1:10 - error TS18042: 'MyType' is a type and cannot be imported in JavaScript files. Use 'import("./types").MyType' in a JSDoc type annotation.
1 import { MyType } from './types'
~~~~~~OR (without --pretty flag):
docs/18042/index.js(1,10): error TS18042: 'MyType' is a type and cannot be imported in JavaScript files. Use 'import("./types").MyType' in a JSDoc type annotation.