-
Notifications
You must be signed in to change notification settings - Fork 33
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
fix: 🐛 use ECMAScript syntax to import ajv #19
Merged
ForbesLindesay
merged 6 commits into
ForbesLindesay:master
from
johngeorgewright:fix/17-import-syntax
Jun 19, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
19c84ca
fix: 🐛 use ECMAScript syntax to import ajv
johngeorgewright 3236463
feat: 🎸 build different template dependening on module interop
johngeorgewright 977a2ff
test: 💍 remove unneccessary teardown
johngeorgewright c195af9
feat: load TS config at top function
johngeorgewright 55c4519
test: 💍 remove built files on teardown
johngeorgewright 33ae370
test: 💍 remove built files on teardown
johngeorgewright File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
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.
One problem I noticed is that
typescript-json-validator
will pull from the project'stsconfig.json
file, even if the project was run with a different config file, IE,tsconfig.test.json
.