Skip to content

Commit d6580a5

Browse files
authored
Migrate @fluent/react to TypeScript (#458)
* Migrate @fluent/react to TypeScript * Fix paths in fluent-gecko * Return ReactElement from Localized React typings (wrongly) expect the return type of functional components to be a ReactElement, thus making () => "Hello" invalid. This is incorrect; as of React 16, it's possible to return plain strings from functional components and Component.render(). See DefinitelyTyped#18912 and TypeScript#21699. To work around this, annotate the return value of Localized to be of type ReactElement, and whenever a string or null are returned, wrap them in Fragments. * Add the build make target * Fix compat.js make target * Export props interfaces * Export MarkupParser type * Fix return type of withLocalization * Convert elems keys to lowercase; lookup via Element.localName * Use Node.nodeName.toLowerCase() for elems lookup * Add a comment about bundle.getMessage(id)! * Move src/vendor out of src/
1 parent d986155 commit d6580a5

35 files changed

+275
-197
lines changed

eslint_src.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
"no-unreachable": 1,
2323
"no-unexpected-multiline": 2,
2424
"no-sparse-arrays": 2,
25-
"complexity": [
26-
1,
27-
18
28-
],
2925
"dot-location": [
3026
2,
3127
"property"

fluent-bundle/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test: esm/.compiled
2323
--require esm \
2424
test/**/*_test.js
2525

26+
.PHONY: build
2627
build: index.js compat.js
2728

2829
index.js: esm/.compiled

fluent-dedent/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test: esm/.compiled
2323
--require esm \
2424
test/**/*_test.js
2525

26+
.PHONY: build
2627
build: index.js compat.js
2728

2829
index.js: esm/.compiled

fluent-dom/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ test:
1111
--require ./test/index \
1212
test/**/*_test.js
1313

14+
.PHONY: build
1415
build: index.js compat.js
1516

1617
index.js: $(SOURCES)

fluent-gecko/makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ test:
1212
--require esm \
1313
test/**/*_test.js
1414

15+
.PHONY: build
1516
build: Fluent.jsm FluentSyntax.jsm Localization.jsm DOMLocalization.jsm l10n.js fluent-react.js
1617

1718
Fluent.jsm: $(SOURCES)
@@ -53,6 +54,7 @@ l10n.js: $(SOURCES)
5354
@echo -e " $(OK) $@ built"
5455

5556
fluent-react.js: $(SOURCES)
57+
$(MAKE) -sC ../fluent-react compile
5658
@rollup $(CURDIR)/src/fluent-react.js \
5759
--config ./vendor_config.js \
5860
--output.intro "/* $(call version,fluent-react) */" \

fluent-gecko/src/fluent-react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "../../fluent-react/src/index.js";
1+
export * from "../../fluent-react/esm/index.js";

fluent-langneg/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test:
99
--require esm \
1010
test/**/*_test.js
1111

12+
.PHONY: build
1213
build: index.js compat.js
1314

1415
index.js: $(SOURCES)

fluent-react/.esdoc.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

fluent-react/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
esm/
12
/index.js
23
/compat.js

fluent-react/.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
.nyc_output
22
coverage
3-
docs
3+
esm/.compiled
44
examples
5+
src
56
test
67
makefile
78
babel.config.js
89
compat_config.js
10+
tsconfig.json

0 commit comments

Comments
 (0)