-
Notifications
You must be signed in to change notification settings - Fork 132
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
Rebuild for TypeScript #514
Changes from 8 commits
770c2ec
ab1247c
b3a9f47
a350e77
840fe99
9e9a18f
7515613
6b1f465
5b9412a
cdad744
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
{ | ||
"plugins": ["@babel/plugin-proposal-class-properties"], | ||
"presets": [ | ||
["@babel/preset-env", { "modules": false }], | ||
"@babel/preset-react" | ||
"@babel/preset-react", | ||
"@babel/preset-typescript" | ||
], | ||
"plugins": ["@babel/plugin-proposal-class-properties"], | ||
"env": { | ||
"test": { | ||
"plugins": ["@babel/plugin-proposal-class-properties"], | ||
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]] | ||
"presets": [ | ||
["@babel/preset-env", { "targets": { "node": "current" } }] | ||
] | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,21 +20,25 @@ | |
"homepage": "https://react-countup.now.sh", | ||
"main": "build", | ||
"files": [ | ||
"build", | ||
"index.d.ts" | ||
"build" | ||
], | ||
"typings": "index.d.ts", | ||
"typings": "build/index.d.ts", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"build": "rollup -c && tsc --emitDeclarationOnly --noEmit false --project src/tsconfig.json --outDir build", | ||
"prepublishOnly": "yarn build", | ||
"test": "jest" | ||
}, | ||
"peerDependencies": { | ||
"react": ">= 16.3.0" | ||
}, | ||
"dependencies": { | ||
"@babel/preset-typescript": "^7.14.5", | ||
"@rollup/plugin-node-resolve": "^13.0.2", | ||
"@rollup/plugin-typescript": "^8.2.3", | ||
"@types/warning": "^3.0.0", | ||
"countup.js": "^2.0.7", | ||
"prop-types": "^15.7.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i suppose that we can remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. derp, yes I've now cleaned up package.json to put deps in the right place and remove |
||
"typescript": "^4.3.5", | ||
"warning": "^4.0.3" | ||
}, | ||
"devDependencies": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": {/* Basic Options */ | ||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ | ||
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ | ||
"declaration": true, /* Generates corresponding '.d.ts' file. */ | ||
"noEmit": true, /* Do not emit outputs. */ | ||
|
||
/* Strict Type-Checking Options */ | ||
"strict": true, /* Enable all strict type-checking options. */ | ||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ | ||
"strictNullChecks": true, /* Enable strict null checks. */ | ||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ | ||
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ | ||
|
||
/* Additional Checks */ | ||
"noUnusedLocals": true, /* Report errors on unused locals. */ | ||
"noUnusedParameters": true, /* Report errors on unused parameters. */ | ||
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ | ||
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ | ||
|
||
"esModuleInterop": true, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep babel only for test files? I suppose that we can use ts-jest. But it can be done in separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC my implementation transpiles typescript using @babel/preset-typescript for both the build and tests. This is generally recommended instead of using the Typescript compiler when Babel is used for the test of transpilation instead of combining methods.
If I'm wrong about that I'll double check when I have some dev time.
Tsc is used to generate d.ts files themselves, as babel only transpiles to javascript.
I also recommend using the same transpilation method for jest as the project itself, so there aren't transpilation differences that cause test failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed, this PR uses babel to transpile typescript for both build and test.