-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add TypeScript support #11
Open
simply-alliv
wants to merge
15
commits into
rwieruch:master
Choose a base branch
from
simply-alliv:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
… and object spread proposals
…cript files and remove the .js extension on the entry path to allow index.tsx to be found
- install weback-env types to resolve "Property 'hot' does not exist on type 'NodeModule'" error from index.tsx file
…e safety - add settings to resolve imports with file extensions other than .js for ESLint's "Cannot find module 'module'" error
- use TypeScript interface to replace propTypes
- update build and start scripts to use .ts extensions for webpack
Typescript support
simply-alliv
changed the title
- run npm audit fix for lodash dependency
Add TypeScript support
Oct 21, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After cloning a forked version of your repo and running npm install, there were security vulnerabilities found with the version of lodash your repo was using. So this is the updated repo after running npm audit fix.
Have implemented TypeScript into the repo. Things to note:
I have removed prop-types from code and package.json as requested and replaced it with
typescript types.
Due to your "minimalistic" TypeScript support requirement. I opted to use @babel/preset-
typescript. It allows babel to be able to transpile TypeScript syntax so that that ESLint and Babel
can work well with TypeScript files. Due to this, you'll find that the typescript package is not
installed as it is not a requirement for the project to work. There are some pros and cons to this
approach. The pro I know of being that:
- Babel has plugins that allow you to use JavaScript syntax that is not yet supported by
TypeScript.
The cons I know of being that:
- TypeScript files won't have any type checking since Babel can only transpile the code. Meaning
that Babel will still compile code even if it has type errors.
Although I believe that ESLint might be utilised well here to provide some form of type
checking. But I am not sure how effective and type safe this approach might be yet.
- Some constructs don't currently compile in Babel, with or without TypeScript:
1. namespaces
2. bracket style type-assertion/cast syntax regardless of when JSX is enabled (i.e. writing
x won’t work even in .ts files if JSX support is turned on, but you can instead write
x as Foo).
3. enums that span multiple declarations (i.e. enum merging)
4. legacy-style import/export syntax (i.e. import foo = require(...) and export = foo)
Add type safety for title prop
Replaced prop-types with TypeScript types.
Alternatives:
Include typescript as a package and let it do the type checking. Allows for type checking through
continuous integration and other features such as emitting declaration files for the .js files in a
production build.
Personally, I think adding the typescript package and running the type checking through the TypeScript compiler with no emit is the best option insteading of using the @typescript-eslint package or letting ESLint do some basic type checks. But I leave that choice up to you.