Skip to content
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

Update NPM packages #63

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ clean:

# Lint (source & built)
lint:
yarn eslint . --fix --ext .js,.ts
yarn eslint . ./test ./examples --fix --ext .js,.ts

# Run the complete test suite from test project
test:
Expand Down
3,630 changes: 1,859 additions & 1,771 deletions examples/yarn.lock

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
},
"homepage": "https://github.com/janjakubnanista/ts-type-checked#readme",
"devDependencies": {
"@rollup/plugin-node-resolve": "^8.1.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@types/node": "^14.0.18",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@wessberg/rollup-plugin-ts": "^1.2.27",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-sort-imports-es6-autofix": "^0.5.0",
"husky": "^4.2.5",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"husky": "^6.0.0",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"rollup": "^2.20.0",
"rollup-plugin-copy": "^3.3.0",
"typescript": "^3.9.6"
"typescript": "^4.2.4"
},
"husky": {
"hooks": {
Expand All @@ -46,5 +46,8 @@
"*.{js,ts}(x)?": [
"eslint --fix"
]
},
"scripts": {
"prepare": "husky install"
}
}
5 changes: 3 additions & 2 deletions src/transformer/typeDescriptor/typeDescriptorGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getDOMElementClassName } from './utils/getDOMElementClassName';
import { getLibraryTypeDescriptorName } from './utils/getLibraryTypeDescriptorName';
import { getPropertyTypeDescriptors } from './utils/getPropertyTypeDescriptors';
import ts from 'typescript';
import { typeFlags } from '../utils/debug';

/**
* A factory for TypeDescriptorGenerator functions.
Expand Down Expand Up @@ -95,7 +96,7 @@ export const createTypeDescriptorGenerator = (program: ts.Program, logger: Logge
if (assert.isNever(type)) return { _type: 'never' };

// For the checks below we need access to the TypeNode for this type
const typeNode = typeChecker.typeToTypeNode(type, scope);
const typeNode = typeChecker.typeToTypeNode(type, scope, undefined);
const typeName = typeChecker.typeToString(type, scope);

// True
Expand Down Expand Up @@ -263,5 +264,5 @@ export const createTypeDescriptorGenerator = (program: ts.Program, logger: Logge
});
}

throw new Error('Unable to describe type ' + typeName);
throw new Error('Unable to describe type ' + typeName + '\n\n' + typeFlags(type));
};
10 changes: 5 additions & 5 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"devDependencies": {
"@types/jest": "^26.0.4",
"@types/node": "^14.0.18",
"@types/react": "^16.9.41",
"fast-check": "^1.25.1",
"@types/react": "^17.0.3",
"fast-check": "^2.14.0",
"jest": "^26.1.0",
"react": "^16.13.1",
"react": "^17.0.2",
"semver": "^7.3.2",
"ts-jest": "^26.1.1",
"ts-node": "^8.10.2",
"ts-node": "^9.1.1",
"tslib": "^2.0.0",
"ttypescript": "^1.5.10",
"typescript": "^3.9.6"
"typescript": "^4.2.4"
},
"workspaces": [
"setups/*"
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/test-with-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ for MATCHING_SETUP in $MATCHING_SETUPS; do
yarn workspace "$MATCHING_SETUP" run jest "$TEST_PATTERN"
else
# In debug mode node is started with inspect flag
yarn workspace "$MATCHING_SETUP" node --inspect-brk $(which jest) "$TEST_PATTERN" --runInBand
yarn workspace "$MATCHING_SETUP" node --inspect $(which jest) "$TEST_PATTERN" --runInBand
fi

printf "\n\n\n"
Expand Down
4 changes: 2 additions & 2 deletions test/setups/react/tests/react.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('React', () => {
class TestClassComponent extends React.Component {}
class TestPureClassComponent extends React.PureComponent {}

const reactComponentTypeArbitrary: fc.Arbitrary<React.ComponentType> = fc.constantFrom<React.ComponentType>(
const reactComponentTypeArbitrary: fc.Arbitrary<React.ComponentType> = fc.constantFrom<React.ComponentType<{}>[]>(
TestFunctionComponent,
TestClassComponent,
TestPureClassComponent,
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('React', () => {
const validArbitrary: fc.Arbitrary<TypeReference1> = reactComponentTypeArbitrary;
const invalidArbitrary = oneOf(
primitive(),
fc.constantFrom<any>({}, <div />, <TestFunctionComponent />, <TestClassComponent />, <TestPureClassComponent />),
fc.constantFrom<any[]>({}, <div />, <TestFunctionComponent />, <TestClassComponent />, <TestPureClassComponent />),
);

assert(validArbitrary, invalidArbitrary, [
Expand Down
6 changes: 3 additions & 3 deletions test/setups/typescript--2.7.2/tests/arrays.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('arrays', () => {
type TypeReference1 = string[];

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.array(fc.string());
const invalidSpecialCases = fc.constantFrom<any[]>([6], ['string', true]);
const invalidSpecialCases = fc.constantFrom<any[][]>([6], ['string', true]);

const invalidArbitrary = fc.oneof(
invalidSpecialCases,
Expand All @@ -34,9 +34,9 @@ describe('arrays', () => {
type LiteralType = 'a' | 'b';
type TypeReference1 = LiteralType[];

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.array(fc.constantFrom<LiteralType>('a', 'b'));
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.array(fc.constantFrom<LiteralType[]>('a', 'b'));
const invalidArbitrary = fc.oneof(
fc.constantFrom<any[]>([6], ['string', true]),
fc.constantFrom<any[][]>([6], ['string', true]),
fc.anything().filter(notAnArray),
fc.array(fc.anything().filter(notOfType('string'))).filter(notAnEmptyArray),
);
Expand Down
8 changes: 4 additions & 4 deletions test/setups/typescript--2.7.2/tests/basics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('basics', () => {
type TypeReference1 = object;

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.oneof(
fc.constantFrom<TypeReference1>(
fc.constantFrom<TypeReference1[]>(
{},
new Object(),
() => true,
Expand All @@ -147,7 +147,7 @@ describe('basics', () => {
fc.func(fc.anything()),
);
const invalidArbitrary = fc.oneof(
fc.constantFrom<any>(true, false, undefined, null, 6, 'string', Symbol('a')),
fc.constantFrom<any[]>(true, false, undefined, null, 6, 'string', Symbol('a')),
primitive(),
);

Expand All @@ -158,7 +158,7 @@ describe('basics', () => {
type TypeReference1 = Object; // eslint-disable-line @typescript-eslint/ban-types

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.oneof(
fc.constantFrom<TypeReference1>(
fc.constantFrom<TypeReference1[]>(
{},
new Object(),
new String(),
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('basics', () => {
type TypeReference1 = 'a' | 'b' | 'c' | 9 | false | true;
const literalTypeValues: TypeReference1[] = ['a', 'b', 'c', 9, false, true];

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>(...literalTypeValues);
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>(...literalTypeValues);
const invalidArbitrary = fc.anything().filter(notALiteral(...literalTypeValues));

assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]);
Expand Down
8 changes: 4 additions & 4 deletions test/setups/typescript--2.7.2/tests/indexed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('string-indexed types', () => {
);

const invalidArbitrary = oneOf<any>(
fc.constantFrom<any>(
fc.constantFrom<any[]>(
{ property: 'string' },
Object.assign(() => true, { property: 'string' }),
),
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('string-indexed types', () => {
);

const invalidArbitrary = oneOf(
fc.constantFrom<any>(
fc.constantFrom<any[]>(
{ property: 'string' },
Object.assign(() => true, { property: 'string' }),
),
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('string-indexed types', () => {
);

const invalidArbitrary = oneOf(
fc.constantFrom<any>(
fc.constantFrom<any[]>(
{ 6: 'string' },
Object.assign(() => true, { 7: 'string' }),
),
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('string-indexed types', () => {
);

const invalidArbitrary = oneOf(
fc.constantFrom<any>(
fc.constantFrom<any[]>(
{ 6: 'string' },
{ 6: 'literal', property: () => false },
Object.assign(() => true, { 7: 'string' }),
Expand Down
8 changes: 4 additions & 4 deletions test/setups/typescript--2.7.2/tests/interfaces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('interface types', () => {
type TypeReference1 = {};

const validArbitrary: fc.Arbitrary<TypeReference1> = oneOf<TypeReference1>(
fc.constantFrom<TypeReference1>(
fc.constantFrom<TypeReference1[]>(
{},
[],
['string'],
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('interface types', () => {
);

const invalidPropertyArbitrary = fc.anything().filter(notOfType('string'));
const invalidSpecialCases = fc.constantFrom<any>({}, { a: false });
const invalidSpecialCases = fc.constantFrom<any[]>({}, { a: false });
const invalidArbitrary = oneOf(
invalidSpecialCases,
primitive(),
Expand All @@ -79,7 +79,7 @@ describe('interface types', () => {
toString: () => string;
}

const validSpecialCases: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>(
const validSpecialCases: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>(
{},
new Object(),
() => true,
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('interface types', () => {
property?: string;
}

const validSpecialCases: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>(
const validSpecialCases: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>(
{},
new Object(),
{ property: undefined },
Expand Down
14 changes: 7 additions & 7 deletions test/setups/typescript--2.7.2/tests/literals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('literals', () => {
test('string', () => {
type TypeReference1 = 'a';

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>('a');
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>('a');
const invalidArbitrary = fc.anything().filter(notALiteral('a'));

assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]);
Expand All @@ -19,7 +19,7 @@ describe('literals', () => {
test('number', () => {
type TypeReference1 = 6;

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>(6);
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>(6);
const invalidArbitrary = fc.anything().filter(notALiteral(6));

assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]);
Expand All @@ -28,7 +28,7 @@ describe('literals', () => {
test('true', () => {
type TypeReference1 = true;

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>(true, !0, !!1);
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>(true, !0, !!1);
const invalidArbitrary = fc.anything().filter(notALiteral(true));

assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]);
Expand All @@ -37,7 +37,7 @@ describe('literals', () => {
test('false', () => {
type TypeReference1 = false;

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>(false, !!0, !1);
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>(false, !!0, !1);
const invalidArbitrary = fc.anything().filter(notALiteral(false));

assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]);
Expand All @@ -48,7 +48,7 @@ describe('literals', () => {
test('primitive', () => {
type TypeReference1 = 'a' | 6 | false;

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1>('a', 6, false);
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.constantFrom<TypeReference1[]>('a', 6, false);
const invalidArbitrary = fc.anything().filter(notALiteral('a', 6, false));

assert(validArbitrary, invalidArbitrary, [typeCheckFor<TypeReference1>(), (value) => isA<TypeReference1>(value)]);
Expand All @@ -58,7 +58,7 @@ describe('literals', () => {
type TypeReference1 = string[] | { property: string };

const validArbitrary: fc.Arbitrary<TypeReference1> = oneOf(
fc.constantFrom<TypeReference1>(
fc.constantFrom<TypeReference1[]>(
[],
['string'],
{ property: 'string' },
Expand All @@ -70,7 +70,7 @@ describe('literals', () => {
}),
);
const invalidArbitrary = oneOf<any>(
fc.constantFrom<any[]>([6], ['string', true]),
fc.constantFrom<any[][]>([6], ['string', true]),
primitive(),
fc.array(fc.anything().filter(notOfType('string'))).filter(notAnEmptyArray),
fc.record({
Expand Down
2 changes: 1 addition & 1 deletion test/setups/typescript--2.7.2/tests/map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Map', () => {
fc.array(fc.tuple(numeric(), fc.string())).map((entries) => new Map(entries)),
);
const invalidArbitrary = oneOf(
fc.constantFrom<any>({}, new Map([['key', 'value']]), new Set(), new Date()),
fc.constantFrom<any[]>({}, new Map([['key', 'value']]), new Set(), new Date()),
primitive(),
);

Expand Down
4 changes: 2 additions & 2 deletions test/setups/typescript--2.7.2/tests/resolution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('type resolution', () => {
bProperty = 'Britney Spears';
}

const instantiable = fc.constantFrom<new () => any>(Object, Array, Number, Boolean, Function, Date, Error, A, B);
const instantiable = fc.constantFrom<(new () => any)[]>(Object, Array, Number, Boolean, Function, Date, Error, A, B);

test('simple reference', () => {
type TypeReference1 = string;
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('type resolution', () => {

const validArbitrary: fc.Arbitrary<TypeReference1> = fc.func(fc.anything() as fc.Arbitrary<any>);
const invalidArbitrary = oneOf(
fc.constantFrom<any>({}, 'string', false),
fc.constantFrom<any[]>({}, 'string', false),
fc.anything().filter(notOfType('function')),
);

Expand Down
2 changes: 1 addition & 1 deletion test/setups/typescript--2.8.3/tests/conditional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('conditional types', () => {
string: string;
};
type TypeReference1 = ConditionalPropertyNames<Interface>;
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.oneof(fc.constantFrom<TypeReference1>('numeric'));
const validArbitrary: fc.Arbitrary<TypeReference1> = fc.oneof(fc.constantFrom<TypeReference1[]>('numeric'));
const invalidArbitrary: fc.Arbitrary<any> = fc.oneof(
fc.constantFrom('string'),
fc.anything().filter(notALiteral('numeric')),
Expand Down
6 changes: 3 additions & 3 deletions test/setups/typescript--2.9.1/tests/indexed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('number-indexed types', () => {
);

const invalidArbitrary = fc.oneof(
fc.constantFrom<any>(
fc.constantFrom<any[]>(
{ 1: 'string' },
Object.assign(() => true, { 3: 'string' }),
),
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('number-indexed types', () => {
);

const invalidArbitrary = fc.oneof(
fc.constantFrom<any>(
fc.constantFrom<any[]>(
{ 6: 'string' },
Object.assign(() => true, { 7: 'string' }),
),
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('number-indexed types', () => {
);

const invalidArbitrary = fc.oneof(
fc.constantFrom<any>(
fc.constantFrom<any[]>(
{ 6: 'string' },
{ 6: 'literal', property: () => false },
Object.assign(() => true, { 7: 'string' }),
Expand Down
Loading