Invalid TypeScript Type (Default Export)
See original GitHub issuePostCSS exports default type as seen in the type file:
https://github.com/postcss/postcss/blob/master/lib/postcss.d.ts
However that is certainly not the case because a code calling default exported type will not run:
import postcss from 'postcss';
const postcssResult = await postcss([autoprefixer])
.process(sassResult.css, postcssOptions);
TypeError: postcss_1.default is not a function
Instead, shouldn’t the TypeScript declaration use export =
?
https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require
Not to mention, calling import postcss = require('postcss');
from TypeScript will not compile anymore due to this type declaration change!
Workaround for those affected by this issue: revert back to PostCSS 7
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Typescript default export undefined - Stack Overflow
With current version of typescript (2.6 or below), you need to write your definition file with export assignment instead of default export:
Read more >TypeScript errors and how to fix them
When you are importing a module with built-in TypeScript declarations and TypeScript tells you that this module does not have a default export,...
Read more >Avoid Export Default - TypeScript Deep Dive - Gitbook
Discoverability is very poor for default exports. You cannot explore a module with intellisense to see if it has a default export or...
Read more >Content Types - ESBuild
#The default export can be error-prone. The ES module format (i.e. ESM) have a special export called default that sometimes behaves differently than...
Read more >How To Use Modules in TypeScript | DigitalOcean
src/vector2.ts:1:1 - error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, move from “commonjs
.js
and.mjs
” to “esm.js
and.cjs
” should help. In this case typings will be correct.TS doesn’t support
.mjs
files yet, so current typings lie. Typings should be rewritten to commonjsdeclare namespace ...
andexport = X
style 😞