-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot redefine property: default #38679
Comments
This is likely a duplicate of #38540 |
I actually can't reproduce the issue in the OP - @zhinanchendd01 is there more context to this? Or a specific set of compiler options? I've tried both with and without |
I just had this with TypeScript 3.9.3. This is my tsconfig.json:
I found out that this fails:
But this works:
|
This solved the whole thing.. Thank you |
Same exact thing is happening to me with sequelize right after going from |
Just saw there's a fix already in #38540 |
my {
"compileOnSave": true,
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"esModuleInterop": true,
"outDir": "dist",
"baseUrl": "src",
},
"exclude": ["dist", "node_modules"]
}
const info = (...args) => {
console.log(...args)
}
const debug = (...args) => {
console.debug(...args)
}
module.exports = { info, debug }
module.exports.default = { info, debug }
this failed: import * as logger from './logger'
logger.debug('debug 1')
// TypeError: Cannot redefine property: default this can work: import logger from './logger'
logger.debug('debug 1') |
const info = (...args) => {
console.log(...args)
}
const debug = (...args) => {
console.debug(...args)
}
module.exports.default = { info, debug }
import logger from './logger'
logger.info('info')
// TypeError: logger_1.default.info is not a function
console.log(logger)
// { default: { info: [Function: info], debug: [Function: debug] } } |
microsoft/TypeScript#38679 to resolve 'TypeError: Cannot redefine property: default'; [package.json,package-lock.json] Bump version
This actually appears to be fixed for my code in v3.9.4, but it's not currently published to npm with the |
I have exactly the same issue – for some reason I cannot write:
I have to split it into two lines. EDIT: Seems to be fixed when using [email protected] |
This helps me.
|
TypeScript Version: 3.9.3
Code
file1.js
file2.ts
Actual behavior:
Related Issues: #38552
The text was updated successfully, but these errors were encountered: