-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(exampe): add typescript sample
- Loading branch information
Showing
11 changed files
with
1,348 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
} | ||
} | ||
], | ||
"@babel/preset-flow", | ||
"@babel/preset-react" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = function (api) { | ||
api.cache(true) | ||
|
||
return { | ||
presets: ['@babel/preset-react', '@babel/preset-typescript'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"App": { | ||
"hello": "Hello Button", | ||
"submit": "Submit Button" | ||
}, | ||
"a": { | ||
"hello": "hello", | ||
"world": "world" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"App": { | ||
"hello": "", | ||
"submit": "" | ||
}, | ||
"a": { | ||
"hello": "", | ||
"world": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "with-typescript", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"i18n": "extract-messages -l=en,ja -o i18n -d en 'src/**/*.{ts,tsx}'" | ||
}, | ||
"dependencies": { | ||
"react": "^16.13.1", | ||
"react-intl": "^4.3.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.9.0", | ||
"@babel/preset-react": "^7.9.4", | ||
"@babel/preset-typescript": "^7.9.0", | ||
"extract-react-intl-messages": "latest", | ||
"typescript": "^3.8.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import { injectIntl, useIntl } from 'react-intl' | ||
|
||
export const SubmitButton = injectIntl(({ intl }) => { | ||
const label = intl.formatMessage({ | ||
id: 'App.submit', | ||
defaultMessage: 'Submit Button' | ||
}) | ||
return <button aria-label={label}>{label}</button> | ||
}) | ||
|
||
export const HelloButton = () => { | ||
const intl = useIntl() | ||
const label = intl.formatMessage({ | ||
id: 'App.hello', | ||
defaultMessage: 'Hello Button' | ||
}) | ||
return <button aria-label={label}>{label}</button> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineMessages } from 'react-intl' | ||
|
||
export default defineMessages({ | ||
hello: { | ||
id: 'a.hello', | ||
defaultMessage: 'hello' | ||
}, | ||
world: { | ||
id: 'a.world', | ||
defaultMessage: 'world' | ||
} | ||
}) |
Oops, something went wrong.