tdegrunt / jsonschema

JSON Schema validation
Other
1.83k stars 262 forks source link

Cannot find name 'function' after upgrade to 1.2.9 #314

Closed pjunlin closed 4 years ago

pjunlin commented 4 years ago

Hi, We meet npm run build error when upgrade this library to version 1.2.9, any idea about this? There is no issue for 1.2.7

node_modules/jsonschema/lib/index.d.ts:98:27 - error TS2304: Cannot find name 'function'.

98 preValidateProperty?: function;

pjunlin commented 4 years ago

@awwright , seems related to your submit in https://github.com/tdegrunt/jsonschema/commit/4ae86101f63627b2d7f9d8f56b5fa548d0b292a4. Thank you!

awwright commented 4 years ago

@pjunlin What is giving you the error? I'm not sure how to write a test for this

pjunlin commented 4 years ago

@awwright does this preValidateProperty?: function syntax related to specific node version , my node -v returns v12.18.0, and my project has dev dependency on your latest 1.2.9 version jsonschema, and it just failed when run npm run build

pjunlin commented 4 years ago

testjsonschema.zip @awwright I upload a very simple project for you to test, just run npm i and npm run build And it fails with

$ npm run build

testjsonschema@1.0.0 build C:\Users\i\Desktop\testjsonschema tsc

node_modules/jsonschema/lib/index.d.ts:98:27 - error TS2304: Cannot find name 'function'.

98 preValidateProperty?: function;



Found 1 error.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! testjsonschema@1.0.0 build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the testjsonschema@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\i\AppData\Roaming\npm-cache\_logs\2020-10-07T06_53_28_162Z-debug.log
zsgalusz commented 4 years ago

function is not valid typescript in the type definition there, it should be capitalised Function

awwright commented 4 years ago

@pjunlin @zsgalusz This should be fixed in 1.2.10, c820ba82ed84fb2366903560c40e9f524425f2bc

Could you consider submitting a PR to add a test for this bug? I'm not sure where to start.

awwright commented 4 years ago

I'm going to close this out because the bugfix is published. Please see #316 for adding tests.