From 8741fddf81274e5834fbd4775dd560b605118442 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 10 Nov 2020 14:23:34 +0100 Subject: [PATCH 1/3] Fix usage of default exports with TypeScript This is done by assigning the property `default` for all properties that are exported using `export default` according to their type definitions. Closes #1424 --- lib/at-rule.js | 1 + lib/comment.js | 1 + lib/container.js | 1 + lib/css-syntax-error.js | 1 + lib/declaration.js | 1 + lib/input.js | 1 + lib/lazy-result.js | 1 + lib/list.js | 1 + lib/node.js | 1 + lib/parse.js | 1 + lib/postcss.js | 1 + lib/previous-map.js | 1 + lib/processor.js | 1 + lib/result.js | 1 + lib/root.js | 1 + lib/rule.js | 1 + lib/stringify.js | 5 ++++- lib/warning.js | 1 + 18 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/at-rule.js b/lib/at-rule.js index 3997fc630..3f4759d78 100644 --- a/lib/at-rule.js +++ b/lib/at-rule.js @@ -20,5 +20,6 @@ class AtRule extends Container { } module.exports = AtRule +AtRule.default = AtRule Container.registerAtRule(AtRule) diff --git a/lib/comment.js b/lib/comment.js index c7f896f81..45ba06c09 100644 --- a/lib/comment.js +++ b/lib/comment.js @@ -10,3 +10,4 @@ class Comment extends Node { } module.exports = Comment +Comment.default = Comment diff --git a/lib/container.js b/lib/container.js index 16de35345..7824848ee 100644 --- a/lib/container.js +++ b/lib/container.js @@ -426,3 +426,4 @@ Container.registerAtRule = dependant => { } module.exports = Container +Container.default = Container diff --git a/lib/css-syntax-error.js b/lib/css-syntax-error.js index 9c4bd466d..e8020c8ba 100644 --- a/lib/css-syntax-error.js +++ b/lib/css-syntax-error.js @@ -89,3 +89,4 @@ class CssSyntaxError extends Error { } module.exports = CssSyntaxError +CssSyntaxError.default = CssSyntaxError diff --git a/lib/declaration.js b/lib/declaration.js index e5e0b79b6..41eb93ee8 100644 --- a/lib/declaration.js +++ b/lib/declaration.js @@ -21,3 +21,4 @@ class Declaration extends Node { } module.exports = Declaration +Declaration.default = Declaration diff --git a/lib/input.js b/lib/input.js index 8d6978360..4c754d14c 100644 --- a/lib/input.js +++ b/lib/input.js @@ -139,6 +139,7 @@ class Input { } module.exports = Input +Input.default = Input if (terminalHighlight && terminalHighlight.registerInput) { terminalHighlight.registerInput(Input) diff --git a/lib/lazy-result.js b/lib/lazy-result.js index e2016fad4..b339bc008 100644 --- a/lib/lazy-result.js +++ b/lib/lazy-result.js @@ -475,5 +475,6 @@ LazyResult.registerPostcss = dependant => { } module.exports = LazyResult +LazyResult.default = LazyResult Root.registerLazyResult(LazyResult) diff --git a/lib/list.js b/lib/list.js index 4e24bf82e..37c77d523 100644 --- a/lib/list.js +++ b/lib/list.js @@ -53,3 +53,4 @@ let list = { } module.exports = list +list.default = list diff --git a/lib/node.js b/lib/node.js index d4532b2a8..fcc057bf6 100644 --- a/lib/node.js +++ b/lib/node.js @@ -288,3 +288,4 @@ class Node { } module.exports = Node +Node.default = Node diff --git a/lib/parse.js b/lib/parse.js index c82797a5b..108d37faf 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -37,5 +37,6 @@ function parse (css, opts) { } module.exports = parse +parse.default = parse Container.registerParse(parse) diff --git a/lib/postcss.js b/lib/postcss.js index dc9c7824e..c11d0d7e0 100644 --- a/lib/postcss.js +++ b/lib/postcss.js @@ -85,3 +85,4 @@ postcss.Node = Node LazyResult.registerPostcss(postcss) module.exports = postcss +postcss.default = postcss diff --git a/lib/previous-map.js b/lib/previous-map.js index 5e73eabe5..5f9265c86 100644 --- a/lib/previous-map.js +++ b/lib/previous-map.js @@ -140,3 +140,4 @@ class PreviousMap { } module.exports = PreviousMap +PreviousMap.default = PreviousMap diff --git a/lib/processor.js b/lib/processor.js index a93d57312..629b8acf7 100644 --- a/lib/processor.js +++ b/lib/processor.js @@ -65,5 +65,6 @@ class Processor { } module.exports = Processor +Processor.default = Processor Root.registerProcessor(Processor) diff --git a/lib/result.js b/lib/result.js index a6fd1a7ae..208ddf603 100644 --- a/lib/result.js +++ b/lib/result.js @@ -39,3 +39,4 @@ class Result { } module.exports = Result +Result.default = Result diff --git a/lib/root.js b/lib/root.js index 3fc2ec5a2..97fb278ab 100644 --- a/lib/root.js +++ b/lib/root.js @@ -56,3 +56,4 @@ Root.registerProcessor = dependant => { } module.exports = Root +Root.default = Root diff --git a/lib/rule.js b/lib/rule.js index 4a32563b1..fe0c6060b 100644 --- a/lib/rule.js +++ b/lib/rule.js @@ -22,5 +22,6 @@ class Rule extends Container { } module.exports = Rule +Rule.default = Rule Container.registerRule(Rule) diff --git a/lib/stringify.js b/lib/stringify.js index ca63a8f93..c39a9fa0a 100644 --- a/lib/stringify.js +++ b/lib/stringify.js @@ -2,7 +2,10 @@ let Stringifier = require('./stringifier') -module.exports = function stringify (node, builder) { +function stringify (node, builder) { let str = new Stringifier(builder) str.stringify(node) } + +module.exports = stringify +stringify.default = stringify diff --git a/lib/warning.js b/lib/warning.js index ff284418c..d40f53390 100644 --- a/lib/warning.js +++ b/lib/warning.js @@ -32,3 +32,4 @@ class Warning { } module.exports = Warning +Warning.default = Warning From e73825414e06c4a5510ba8c04882d7ea01c47286 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 10 Nov 2020 14:26:54 +0100 Subject: [PATCH 2/3] Remove `esModuleInterop` option from tsconfig.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This options looses type strictness. This causes TypeScript tests to work, but that doesn’t mean the same imports would work for users who don’t use `esModuleInterop`. --- tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 9d5267d96..48d84758d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "module": "commonjs", "allowJs": true, "strict": true, - "noEmit": true, - "esModuleInterop": true + "noEmit": true } } From 97a41a863c993caf6f1119438c0861dc5b33f9cf Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 10 Nov 2020 14:51:31 +0100 Subject: [PATCH 3/3] Revert "Remove `esModuleInterop` option from tsconfig.json" This reverts commit e73825414e06c4a5510ba8c04882d7ea01c47286. The current ESLint setup conflicts with itself when using `import stripAnsi = require('strip-ansi')`, which is what should actually be used. --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 48d84758d..9d5267d96 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "module": "commonjs", "allowJs": true, "strict": true, - "noEmit": true + "noEmit": true, + "esModuleInterop": true } }