-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
305 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env", "@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,18 @@ | ||
# ts-overrides-plugin example | ||
|
||
Before all: | ||
|
||
```bash | ||
yarn ts-patch install | ||
``` | ||
|
||
Commands: | ||
|
||
```bash | ||
yarn build:tsc | ||
yarn build:ts-loader | ||
yarn build:fork-ts | ||
yarn watch:tsc | ||
yarn watch:ts-loader | ||
yarn watch:fork-ts | ||
``` |
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,29 @@ | ||
{ | ||
"name": "example-ts4", | ||
"scripts": { | ||
"build:tsc": "tsc", | ||
"build:ts-loader": "webpack --config webpack.config.ts-loader.js", | ||
"build:fork-ts": "webpack --config webpack.config.fork-ts.js", | ||
"watch:tsc": "tsc --watch", | ||
"watch:ts-loader": "webpack --config webpack.config.ts-loader.js --watch", | ||
"watch:fork-ts": "webpack --config webpack.config.fork-ts.js --watch", | ||
"prepare": "ts-patch install -s" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.23.6", | ||
"@babel/preset-env": "^7.23.6", | ||
"@babel/preset-typescript": "^7.23.3", | ||
"@types/babel__core": "^7", | ||
"@types/babel__preset-env": "^7", | ||
"babel-loader": "^9.1.3", | ||
"fork-ts-checker-webpack-plugin": "^9.0.2", | ||
"ts-loader": "^9.5.1", | ||
"ts-node": "^10.9.2", | ||
"ts-overrides-plugin": "workspce:*", | ||
"ts-patch": "2.1.0", | ||
"typescript": "4.2.4", | ||
"webpack": "^5.89.0", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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,4 @@ | ||
import { getDate as getDateLegacy } from './legacy/getDate'; | ||
import { getDate as getDateModern } from './modern/getDate'; | ||
|
||
console.log({ getDateLegacy, getDateModern }); |
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,16 @@ | ||
// ok with strict: false | ||
export const getDate = (date) => { | ||
const modern: string | undefined = undefined; | ||
|
||
// ok with strict: false | ||
modern.split(''); | ||
|
||
return date.toLocaleDateString('ru-RU', { | ||
day: 'numeric', | ||
month: 'long', | ||
year: 'numeric', | ||
}); | ||
} | ||
|
||
// show `string` on hover in IDE | ||
export const someVar: string | undefined = undefined; |
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,18 @@ | ||
import { someVar } from '../legacy/getDate'; | ||
|
||
// Parameter 'date' implicitly has an 'any' type. | ||
export const getDate = (date) => { | ||
const modern: string | undefined = undefined; | ||
|
||
// Show `string | undefined` on hover in IDE | ||
console.log(someVar); | ||
|
||
// 'modern' is possibly 'undefined' | ||
modern.split(''); | ||
|
||
return date.toLocaleDateString('ru-RU', { | ||
day: 'numeric', | ||
month: 'long', | ||
year: 'numeric', | ||
}); | ||
} |
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,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"outDir": "./dist", | ||
"baseUrl": "./src", | ||
"strict": false, | ||
"noEmit": false, | ||
"skipLibCheck": true, | ||
"plugins": [ | ||
{ | ||
"name": "ts-overrides-plugin", | ||
"transform": "ts-overrides-plugin/cli", | ||
"transformProgram": true, | ||
"overrides": [ | ||
{ | ||
"files": ["src/modern/**/*.{ts,tsx}"], | ||
"compilerOptions": { | ||
"strict": true, | ||
}, | ||
}, | ||
] | ||
}, | ||
] | ||
}, | ||
} |
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,29 @@ | ||
const path = require('path'); | ||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
|
||
module.exports = [ | ||
{ | ||
mode: 'production', | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.join(__dirname, 'build'), | ||
filename: 'main.js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new ForkTsCheckerWebpackPlugin(), | ||
], | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
}, | ||
target: 'web', | ||
} | ||
]; |
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,25 @@ | ||
const path = require('path'); | ||
|
||
module.exports = [ | ||
{ | ||
mode: 'production', | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.join(__dirname, 'build'), | ||
filename: 'main.js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
loader: 'ts-loader', | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
}, | ||
target: 'web', | ||
} | ||
]; |
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
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 |
---|---|---|
|
@@ -43,8 +43,8 @@ | |
"typescript": "5.5.1-rc" | ||
}, | ||
"peerDependencies": { | ||
"ts-patch": "^3.0.0", | ||
"typescript": "^5.0.0" | ||
"ts-patch": "^3.0.0 || ^2.0.0", | ||
"typescript": "^5.0.0 || ^4.0.0" | ||
}, | ||
"license": "MIT", | ||
"packageManager": "[email protected]" | ||
|
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
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
Oops, something went wrong.