-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 use ECMAScript syntax to import ajv if allowSyntheticDefaultIm…
- Loading branch information
1 parent
757331b
commit 9ea471f
Showing
26 changed files
with
425 additions
and
30 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
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import rimrafCB from 'rimraf'; | ||
import {exec as execCB, ExecOptions} from 'child_process'; | ||
import * as path from 'path'; | ||
import {promisify} from 'util'; | ||
|
||
const rimraf = promisify(rimrafCB); | ||
|
||
const testDir = path.join(__dirname, 'build-parameters'); | ||
|
||
const exec = (cmd: string, options: ExecOptions): Promise<string> => | ||
new Promise((resolve, reject) => { | ||
execCB(cmd, options, (error, stdout, stderr) => { | ||
if (error) { | ||
reject(stderr || stdout || error.message); | ||
} else { | ||
resolve(stdout); | ||
} | ||
}); | ||
}); | ||
|
||
const buildProject = async (project: string) => { | ||
await exec(`cp tsconfig.${project}.json tsconfig.json`, {cwd: testDir}); | ||
|
||
await exec(`node ../../../lib/cli ./src/Example.ts ExampleType`, { | ||
cwd: testDir, | ||
}); | ||
|
||
await exec(`npx tsc --project ./tsconfig.json`, { | ||
cwd: testDir, | ||
}); | ||
}; | ||
|
||
beforeAll(() => exec('yarn build', {cwd: process.cwd()})); | ||
|
||
afterEach(() => | ||
Promise.all([ | ||
rimraf(path.join(testDir, 'lib')), | ||
exec('rm tsconfig.json', {cwd: testDir}), | ||
exec('rm src/Example.validator.ts', {cwd: testDir}), | ||
]), | ||
); | ||
|
||
test('ESNext module settings', () => | ||
// We expect a project not to build correctly if it has ES module | ||
// target and no esModuleInterop. | ||
expect(buildProject('esnext')).rejects.toMatch('TS1202:')); | ||
|
||
test('ESNext interop module settings', () => buildProject('esnext-interop')); | ||
|
||
test('ES2015 module settings', () => | ||
expect(buildProject('es2015')).rejects.toMatch('TS1202:')); | ||
|
||
test('ES2015 interop module settings', () => buildProject('es2015-interop')); | ||
|
||
test('UMD module settings', () => buildProject('umd')); | ||
|
||
test('UMD interop module settings', () => buildProject('umd-interop')); | ||
|
||
test('System module settings', () => buildProject('system')); | ||
|
||
test('System interop module settings', () => buildProject('system-interop')); | ||
|
||
test('Common JS module settings', () => buildProject('commonjs')); | ||
|
||
test('Common JS interop module settings', () => | ||
buildProject('commonjs-interop')); |
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,11 @@ | ||
export default interface ExampleType { | ||
value: string; | ||
/** | ||
* @TJS-format email | ||
*/ | ||
email?: string; | ||
/** | ||
* @default 42 | ||
*/ | ||
answer: number; | ||
} |
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 @@ | ||
import '../../../../Example.validator'; |
26 changes: 26 additions & 0 deletions
26
src/__tests__/build-parameters/tsconfig.commonjs-interop.json
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,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "commonjs", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"], | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src"] | ||
} |
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": { | ||
"target": "es2018", | ||
"module": "commonjs", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"] | ||
}, | ||
"include": ["src"] | ||
} |
26 changes: 26 additions & 0 deletions
26
src/__tests__/build-parameters/tsconfig.es2015-interop.json
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,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "es2015", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"], | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src"] | ||
} |
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": { | ||
"target": "es2018", | ||
"module": "es2015", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"] | ||
}, | ||
"include": ["src"] | ||
} |
26 changes: 26 additions & 0 deletions
26
src/__tests__/build-parameters/tsconfig.esnext-interop.json
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,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "esnext", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"], | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src"] | ||
} |
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": { | ||
"target": "es2018", | ||
"module": "esnext", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"] | ||
}, | ||
"include": ["src"] | ||
} |
26 changes: 26 additions & 0 deletions
26
src/__tests__/build-parameters/tsconfig.system-interop.json
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,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "system", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"], | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src"] | ||
} |
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": { | ||
"target": "es2018", | ||
"module": "system", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"] | ||
}, | ||
"include": ["src"] | ||
} |
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,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "umd", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"], | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src"] | ||
} |
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": { | ||
"target": "es2018", | ||
"module": "umd", | ||
"moduleResolution": "Node", | ||
"noImplicitAny": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": false, | ||
"importHelpers": false, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"outDir": "lib", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": false, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"declaration": true, | ||
"lib": ["es2018"] | ||
}, | ||
"include": ["src"] | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import run from '../'; | ||
|
||
// let validate: any; | ||
|
||
test('run', () => { | ||
|
Oops, something went wrong.