Comments (12)
Will be potentially fixed in #199
from fluent-json-schema.
@cyberwombat can you test it with #199 fixes?
from fluent-json-schema.
I think still an issue, additionally it looks like ExtendedSchema
is not exported anymore. Heres a screenshot of errors in VSCode with 199.
What I currently have to do to make it work:
import FJS from 'fluent-json-schema'
export const S = FJS.default
export const fooSchema = S.string().maxLength(200)
Here's my tsconfig:
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"useUnknownInCatchVariables": false,
"target": "es2020",
"lib": ["es2020"],
"module": "node16",
"moduleResolution": "NodeNext",
"esModuleInterop": true, // Eases ESM support
"types": ["node"],
"allowSyntheticDefaultImports": true,
"declaration": true,
"strict": true,
"strictNullChecks": true,
"alwaysStrict": true,
//importsNotUsedAsValues
// "noImplicitAny": false,
"incremental": true,
"noImplicitReturns": false,
"noImplicitThis": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noEmit": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
// "typeRoots": ["./node_modules/@types"]
"resolveJsonModule": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
},
"typeRoots": ["node_modules/@types", "typings"],
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
TS: 4.8.4
from fluent-json-schema.
I think still an issue, additionally it looks like ExtendedSchema is not exported anymore. Heres a screenshot of errors in VSCode with 199.
Fixed in the last commit, please check if you find other issues
from fluent-json-schema.
That fixed the ExtendedSchema
but I am still having original issue with needed to use .default
import S from 'fluent-json-schema'
export const commonLabelSchema = S.default.string()
from fluent-json-schema.
@cyberwombat can I see what you are extending @tsconfig/node16/tsconfig.json
?
I was able to use
import S, { FluentSchemaError, ExtendedSchema } from "..";
console.log("isFluentSchema:", S.object().isFluentJSONSchema);
const schema = S.string()
If we find out what is happening would be nice to reproduce inside the FluentJSONSchema.test-d.ts
from fluent-json-schema.
@cesarvspr @tsconfig/node16/tsconfig.json
extend is not necessary. I can remove it with same issue. What is your tsconfig?
from fluent-json-schema.
I was able to use you provided tsconfig.json file and my own which is
{
"compilerOptions": {
"useUnknownInCatchVariables": false,
"target": "es2020",
"lib": ["es2020"],
"module": "node16",
"moduleResolution": "NodeNext",
}
}
here you can see my test:
minimal_project.zip
from fluent-json-schema.
You need "type":"module"
in package.json
as well for ESM. It fails then.
from fluent-json-schema.
you are right @cyberwombat, but I could not find a solution for this specific case yet.
Btw, why are you using the "type":"module"
?
from fluent-json-schema.
I am migrating to 100% esm and that's part of the jump. If I don't then my code stays CJS when imported. I don't know of a solution except to build as both esm and cjs and using the exporrts
field in package.json od doing the full esm jump as many packages are doing. I heard there is a wrapper out there that can be used to help male the transition but I think it still requires a build output though I am not sure. Maybe this helps https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
from fluent-json-schema.
@climba03003 Would you please help with this? I have a PR ready that just needs to work when we have "type":"module" on the package.json
from fluent-json-schema.
Related Issues (20)
- All props should be required by default HOT 3
- .id and .required not returning schema object HOT 1
- .raw({ nullable: true }) being inserted in the wrong position HOT 6
- Root level `required` creates invalid schema HOT 8
- Support "dependentrequired" and "dependentSchemas" HOT 5
- Support JSON Schema 2019-09 deprecated value HOT 4
- npm package does not match github repo HOT 3
- additionalProperties schemas causing unexpected behavior when passed to oneOf HOT 3
- How we can omit fields from request body that is not defined in the schema.
- .string() method validate all type values HOT 2
- 100 % code coverage HOT 1
- Set $id after clone HOT 7
- Conditional property is not allowed when using additionalProperties(false) HOT 3
- validate GET array of array param HOT 2
- Crashes on import HOT 2
- Nullable false not working HOT 1
- Object schema does not carry properties added by .raw() to a $ref HOT 3
- Object type ignored when nested properties use oneOf and raw HOT 11
- ReferenceError: Cannot access 'User' before initialization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluent-json-schema.